Tuesday, May 8, 2012

String Reverse Example in Java Programming

It is a sample string reverse example. In this program read array of string from user and give output array of reverse string.
Here use StringBuffer class and create object name[] of StringBuffer class. Use method reverse() to reverse inserted string.

Program Code

//developed by Om Prakash
import java.util.*;
class StringReverse
public static void main(String argv[])
int size;
Scanner console=new Scanner(System.in);
System.out.println("*******STRING REVERSE*******");
System.out.print("How many string do you want to enter : ");
StringBuffer name[]=new StringBuffer[size+1];
String temp;
int i;
System.out.println("Enter "+size+" string : ");
name[i]=new StringBuffer(temp);
System.out.println("String after Reverse");


Monday, May 7, 2012


Difference between Java AWT and SWING
1. AWT(Abstract Window Toolkit) is a heavy weight but Swing is a light weight.

2. Swing feel and look better than AWT components.

3. Swing is a pure java components but AWT native components.

4. AWT not have complex components but Swing has additional components like JTable, JProgressBar, JSlider, JTree etc.

5. Applet list has scrollbar but Swing JList does not support scrolling but this can be done using scrollPane.

6. Applet not support MDI(multiple document interface) window but Swing support MDI.

7. Applet default layout is FlowLayout but Swing default layout is BorderLayout.

8. AWT menu item cannot have images or radio buttons or checkboxes but Swing menu item can have images or radio buttons or checkboxes.

9. AWT do not have JMV(Java Model Viewport) but All swing components have JMV.

10. In AWT, components can be added directly on the Frame or window but in Swing while adding components on Frame or window, they have to be added on its content pane.

11. Swing has more powerful and flexible components than AWT.

Applets vs Applications - How Applets Differ From Applications

Java Applets and Java applications have many similarities but there are some differences between applets and applications.
1. Applets not use main() method but applications have main() method.

2. Applets execute in web browser or it embedded with web browser but java applications execute normally.

3. Applets are small programs to do specific task but applications are large programs.

4. Applets must extends java.applet.Applet class but java applications start execution with main() method.

5. Applets can not use libraries from other languages such as C or C++ but applications supports this by native methods.

6. Applet can not run independently. It run in webpage but application runs independently.

7. Applets not able to read or write files from local computer but applications can do such task.

8. Applets can not communicate with other servers on the network.

9. Applets have a life cycle with init(), start(), stop(), paint(), destroy() methods but applications not have such methods.