Skip to main content

Posts

Showing posts from March, 2016

Difference b/w string and string buffer in tabular form In java

Difference b/w string and string buffer in tabular form       String StringBuffer/StringBuilder 1 String Object is  immutable. StringBuffer/StringBuilder Object is mute 2 Immutable  means the value stored in the String object can’t be changed. Mutable  means the value stored in the String object can be changed. 3 Inefficient Efficient. 4 ‘overloaded mathematical operators’ (‘+’) is used for adding strings which generates string new instances everytime. Example: String st = “Hello”; st = st + “Java”; ‘append’ is used for adding two or more strings which expands  StringBuffer. Example: StringBuilder sb = new StringBuilder(“Hello”); sb.append(“Java”); 5 String is not synchronized. Which means it is not thread safe. StringBuilder/StringBuffer is synchronized. Which is thread safe and hence you can use it when you implement threads for methods. 6 Po...

button class example in awt in java

USE OF SHOW AND CLEAR BUTTON IN                          BUTTON CLASS import java.awt.*; import java.applet.*; import java.awt.event.*; /* <applet code="ButtonDemo2" height=200 width=200> </applet> */ public class ButtonDemo2 extends Applet implements ActionListener {             Button b1,b2;             Label msg;             public void init()             {                         msg=new Label("                          ...