Example of string without using the new operator

We write a program which is example of string without using the new operator.

package com.javaforecast4u;

public class StringExample {

    /**
     * @author:arbind
     * @Example of string with using the new operator
     */
    public static void main(String[] args) {
      String str="WELCOMETOJAVAFORECAST4U";
      System.out.println(str);
      System.out.println(str.length());
      System.out.println(str.charAt(3));
      System.out.println(str.charAt(10));
      System.out.println(str.indexOf('T'));
      System.out.println(str.indexOf('O'));
      System.out.println(str.hashCode());
      System.out.println(str.substring(3,7));
      System.out.println(str.substring(5,5));
      System.out.println(str.substring(6,7));
      System.out.println(str.substring(0,6));
      System.out.println(str.substring(5));
      System.out.println(str.substring(4,12));
      System.out.println(str.substring(0,10));
    }

}

2 comments :

  1. hi,,, its very good site ... but if possible then right output also for every program .
    Thanks and regards
    Prashant

    ReplyDelete
  2. Thanks Prashant for your feedback I will give the output of each program....

    ReplyDelete