Friday, February 12, 2016

StringExample8

package StringInJava;

public class StringExample8 {

/**
Suppose s1 and s2 are two string variables. If:

          s1 == s2 :0
          s1 > s2   :positive value
          s1 < s2   :negative value
*/
public static void main(String[] args) {
  String s1="Bhanu";
  String s2="Bhanu";
  String s3="Pratap";
  System.out.println(s1.compareTo(s2));//0
  System.out.println(s1.compareTo(s3));//-14(because s1>s3)
  System.out.println(s3.compareTo(s1));//14(because s3 < s1 )
 
         int a1 = (int)'a';
 
  System.out.println("ascii value of a is :-"+a1);
 
        int a2 = (int)'A';
 
  System.out.println("ascii value of A is :-"+a2);
}



}

2 comments:

  1. hi how can we recognize which is program is for which concept.

    ReplyDelete
  2. Go Through my playlist

    https://www.youtube.com/user/MrBhanupratap29/playlists

    ReplyDelete