Java Tutorial

 
 
 

Basic Programming

Example of searching string for subString Use of If-Else Statement Example of using multiple classes Use of Labeled Break Statement

Extending Classes and Inheritance

Print on same line using multiple print statement Append StringBuffer by StringBuffer, String obj Conditional (Ternary) Operator - ? :

Input - Output - Variables

Example of Overriding a Base Class Method Declare, initialize and print String object Example of getting at characters in a String Operator (>>>) Shift Right - with zeros from left Constructor in class to initialize data member Use of Labeled Continue Statement

StringBuffer

Use of some Character Methods Read input from Standard Input Device Declare, initialize, print StringBuffer object Logical OR Operator (|) in If Statement Static Nested Class outside Top-Level Class Declare, initialize, print array of characters Check start and end of a String Operator (<<) Shift Left - with zero from right Example of creating class and using its object Use of Nested Loop

Arrays

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

Standard Libraray Class Methods

Bitwise Operator (&) AND StringBuffer,String obj,Basic Types to strbuf obj Switch Statement for different case labels

Bitwise Operators

Calling Base Class Method from Derived Class Example of arrays of String Example of searching String for character Use of If Statement Example of overloading constructors in a class Use of Break Statement

Classes

Boolean variable on Standard Output Device Show some properties of StringBuffer object Logical or Boolean Negation i.e. NOT (!) Example of Driving and using a Class Declare, initialize, print 2D array of integers Compare Strings by successive corresponding char Operator (>>) Shift Right - sign bit from left Initialization block - initialize data of class Use of the Continue Statement

String

Use of some Math Methods Increment and Decrement Operators Example of creating string obj from char Array Conditional OR Operator (||) in If Statement Example of using Non-Static Nested Class Search element in array using Linear Search Compare strings for equality Bitwise Operator (~) Complement Example creating String obj from StringBuffer obj Use of Do-While Loop

Continue/Break Statement

Example using Abstract Class and Abstract Method Example of modifying string objects Conditional AND Operator (&&) in If Statement Example of using user-defined package Copy element of array in another in reverse order Print string on Standard Output Device Bitwise Operator (|) OR Example extraction of char from StringBuffer obj Use of For Loop

Conditional Statements - Logical Operators

Example of Polymorphism Example of concatination of Strings
 
 
 public class JAVA_051
 {


    public static void main(String[] args)
    {
       String Text=\"To be or not to be, that is the question; Whether \'this\"
                  +\"nobler in the mind to suffer the sling and arrows of \"
                  +\"outrageous fortune, or to take arms against a sea of \"
                  +\"troubles, and by opposing end them?\";

       System.out.println(\"Text paragraph is : \\n\" + Text + \"\\n\");

       String Str=\"be\";

       int index=Text.indexOf(Str);

       if(index!=-1)
       {
          System.out.println(\"From start, first \\\"\" + Str +
                                 \"\\\" is present at the position : \" + index);

          index+=Str.length( );
       }

       else
          System.out.println(\"\\\"\" + Str + \"\\\" is not present in the above text.\");

       index=Text.indexOf(Str,index);

       if(index!=-1)
          System.out.println(\"From start, second \\\"\" + Str +
                                      \"\\\" is present at the position : \" + index);

       else
          System.out.println(\"\\\"\" + Str + \"\\\" is not present in the above text.\");

       Str=\"of\";

       index=Text.lastIndexOf(Str);

       if(index!=-1)
       {
          System.out.println(\"\\nFrom end, first \\\"\" + Str +
                                     \"\\\" is present at the position : \" + index);

          index-=Str.length( );
       }

       else
          System.out.println(\"\\\"\" + Str + \"\\\" is not present in the above text.\");

       index=Text.lastIndexOf(Str,index);

       if(index!=-1)
          System.out.println(\"From end, second \\\"\" + Str +
                                       \"\\\" is present at the position : \" + index);

       else
          System.out.println(\"\\\"\" + Str + \"\\\" is not present in the above text.\");

    }
 }

    Related Post:
  1. Corba program of Count Client Applet, IDL,Server, Client

  2. Program to show the use of Bitwise Operator (~) Complement

  3. Program that takes a long sentence and a character from the client and count the occurrence of the character in the sentence at the server side

  4. An applet program that displays Text at the center of the string which is passed as parameter

  5. Corba program of UDP client server application which sends the news to the client. Server takes the news from the NewsDataFile located at the server

  6. An applet program to display barchart of given data

  7. Program to evaluate following investment equation V=P(1+R)^N

  8. Program to extract a portion of a character string and print the extracted string

  9. Corba program of game

  10. corba program of client and a DNS server where given a URL the server sends back an IP address

  11. An applet program to take user input and display

  12. CORBA based application for addition of two mathematical expressions of the form (ax + by) and displaying the result on client side

  13. Program to show an example of using a Static Nested Class outside the Top-Level Class

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

  15. Program to declare, initialize and print a StringBuffer object

  16. An applet program to perform selection sort

  17. Program to show the use of Nested Loops

  18. 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..

  19. Program to show an example of Arrays of String

  20. Program to read the ballots and count the votes cast for each candidate using an array variable count

 
 
Didn't find what you were looking for? Find more on Program to show an example of searching Strings for subStrings