Skip to main content

Posts

Showing posts from 2015

Program of packages

                        Program of packages PROGRAM -  make all the program sequentially.. //Save by add.java package c.bmb; public class add {                                     private int a,b;                                     public add(int a,int b) {                                     this.a=a;                  ...

Types of package

              Types of package Packages: Packages is a collection of classes. In java, there are two types of packages:             1. Pre-defined packages             2. User defined packages 1. Pre-defined packages: These packages come with the java library. Some of the packages are listed below: Packages                                                                                       ...

package

                                                                Package Packages: 1.       Introduction: If no package name is specified in any java file then the class is part of the unnamed package. This requires that every class must have a unique name to avoid collision. After a while, without some way to manage the namespace, you could run out of convenient descriptive names for individual classes. You also need some way to be assured that the name you choose for a class will be reasonably unique and not collide with class names chose by other programmers.  Java provides a mechanism for partitioning the class name space into more manageable chunks. This mechanism is the package.                   ...

StringBuffer class 3:

                                                  StringBuffer class 3: 7) append(): This method is used to append or add the character or the string at the end of the string . This method has two forms: append(int ch) append(String s) E.g. StringBuffer sb=new StringBuffer("Quantum"); StringBuffer s; s=sb.append("adcom") ; s= s.append(" is") ; System.out.println(s); Output: Quantumadcom is 8) insert(): This method is used to insert the character or the string at the particular position in the string . This method has the two different forms:                                     insert(int index,int ch);          ...

method of string buffer 2.

                                                          method of string buffer 2. 4) charAt(int index): This method is used to return the character present at the particular index position in the string E.g. StringBuffer sb=new StringBuffer("computer"); System.out.println(sb.charAt(3)); Output : p 5) setCharAt(int index , int ch) The method is used to set the character at a particular index position . E.g. StringBuffer sb=new StringBuffer("hello"); System.out.println(sb); sb.setCharAt(1,'a'); System.out.println(sb); Output: hello hallo 6) getChars(): This method is used to extract the specific group of characters from the string and assign it into the character array. The general form is: getChars(int sindex,int eindex,char t[],int position) Where:        ...