Java Tutorial

 
 
 

Basic Programming

Example of using multiple classes Use of Labeled Break Statement

Extending Classes and Inheritance

Example of searching string for subString Use of If-Else Statement Conditional (Ternary) Operator - ? :

Input - Output - Variables

Example of Overriding a Base Class Method Declare, initialize and print String object Print on same line using multiple print statement Append StringBuffer by StringBuffer, String obj Constructor in class to initialize data member Use of Labeled Continue Statement

StringBuffer

Use of some Character Methods Example of getting at characters in a String Operator (>>>) Shift Right - with zeros from left Static Nested Class outside Top-Level Class Declare, initialize, print array of characters Read input from Standard Input Device Declare, initialize, print StringBuffer object Logical OR Operator (|) in If Statement Use of Nested Loop

Arrays

Example of Copying i.e. Clonning Objects Check start and end of a String Operator (<<) Shift Left - with zero from right Example of creating class and using its object Example of using a Static Nested Class Sort content of an array using Bubble Sort Integer variable on Standard Output Device Example of creating char Array from String obj Logical AND Operator (&) in If Statement Use of While Loop Use of Switch Statement Example of Multiple Levels of Inheritance Use of Comparison operator (==) for String Bitwise Operator (^) XOR (Exclusive OR) Change char in StringBuffer obj- reverse content Example of using a recursive method in class Declare, initialize, print an array of integers

Standard Libraray Class Methods

Example of extracting subString from a String Use of Nested If-Else Statements Switch Statement for different case labels

Bitwise Operators

Calling Base Class Method from Derived Class Example of arrays of String Bitwise Operator (&) AND StringBuffer,String obj,Basic Types to strbuf obj Example of overloading constructors in a class Use of Break Statement

Classes

Example of searching String for character Use of If Statement Logical or Boolean Negation i.e. NOT (!) Example of Driving and using a Class Declare, initialize, print 2D array of integers Boolean variable on Standard Output Device Show some properties of StringBuffer object Use of the Continue Statement

String

Use of some Math Methods Compare Strings by successive corresponding char Operator (>>) Shift Right - sign bit from left Initialization block - initialize data of class Example of using Non-Static Nested Class Search element in array using Linear Search Increment and Decrement Operators Example of creating string obj from char Array Conditional OR Operator (||) in If Statement Use of Do-While Loop

Continue/Break Statement

Example using Abstract Class and Abstract Method Compare strings for equality Bitwise Operator (~) Complement Example creating String obj from StringBuffer obj Example of using user-defined package Copy element of array in another in reverse order Print string on Standard Output Device Example of modifying string objects Conditional AND Operator (&&) in If Statement Use of For Loop

Conditional Statements - Logical Operators

Example of Polymorphism Example of concatination of Strings Bitwise Operator (|) OR Example extraction of char from StringBuffer obj
 
 
 public class JAVA_057
 {


    public static void main(String[] args)
    {
       StringBuffer SB1=new StringBuffer(\"This is a StringBuffer Object!\");

       System.out.println(\"StringBuffer # 1 : \" + SB1);

       System.out.println(\"Length : \" + SB1.length( ));
       System.out.println(\"Capacity : \" + SB1.capacity( ));

       SB1.setLength(20);

       System.out.println(\"\\nStringBuffer # 1 : \" + SB1);
       System.out.println(\"Length : \" + SB1.length( ));
       System.out.println(\"Capacity : \" + SB1.capacity( ));

       StringBuffer SB2=new StringBuffer(15);

       System.out.println(\"\\nStringBuffer # 2 : \" + SB2);
       System.out.println(\"Length : \" + SB2.length( ));
       System.out.println(\"Capacity : \" + SB2.capacity( ));

       SB2=SB1;

       System.out.println(\"\\nStringBuffer # 2 : \" + SB2);
       System.out.println(\"Length : \" + SB2.length( ));
       System.out.println(\"Capacity : \" + SB2.capacity( ));

       SB2.ensureCapacity(50);

       System.out.println(\"\\nStringBuffer # 2 : \" + SB2);
       System.out.println(\"Length : \" + SB2.length( ));
       System.out.println(\"Capacity : \" + SB2.capacity( ));
    }
 }

    Related Post:
  1. RMI based application for login validation based on data saved in text file stored on the server and will display appropriate message to the client..

  2. Program that reads and writes random access file

  3. Given a list of marks ranging form 0 to 100, write a program to compute and print the number of students marks

  4. Program to show an example of using a Non-Static Nested Class

  5. An applet program to give demo of getDocumentBase() and getCodeBase() methods

  6. Program to show the use of Conditional AND Operator (&&) in If Statements

  7. Pass the marks of 10 students from the client side design a servlet, which takes these marks and returns the number of students who obtained first cls

  8. Program of concatenating and Buffering files

  9. An applet program to draw Polygon Graph with given data

  10. Develop a game application in CORBA for which the player will guess a number between 1 to 100, which will be compared to the random number generated b

  11. Program of telnet server - client

  12. Create an interface coversions. Which have the following functions Inchestomillimeters(), hptowatts(),wattstohp(),poundstogram(),gramtopounds()

  13. Program to show an example of using a recursive method in a class

  14. Program of inventory management and demonstrating interactive input and output

  15. Program to read rollno, marks of sub1,sub2 and sub3 and on basis of that display result

  16. Corba program to develop a simple calculator with addition, subtraction, multiplication and division capabilities, data collection from client side

  17. Program to show an example of creating Character Arrays from String objects

  18. Program of an applet to display alternate filled and empty circle

  19. Program to show the use of Break Statement

  20. Program, which creates a three thread. One thread display the numbers from 1 to 5, second thread display the square root of that number etc

 
 
Didn't find what you were looking for? Find more on Program to show some properties of StringBuffer object