Java String Comparison : String into integer

      No Comments on Java String Comparison : String into integer
Mobile Apps Category (English)728x90

Java String Comparison

Java String Comparison

If you are not sure about Java Application  Vs Java Applet

Which method is used to compare two String(Java String Comparison) in java?

To compare two strings you need to use equals method. Example:

String s1  = "Adarsh";
String s2  = "Adarsh";
String s3  = "Patel";

s1.equals(s2);                 // TRUE
s2.equals(s1);                 // TRUE
s3.equals(s3);                 // FALSE

How to generate random number using java?

To generate random number within specific limit you have to use nextInt of Random Class.


Random rand = new Random();

int max = 10;
int min = 1;

// Number will be generated between max and min value. (Between 1 – 10)

int randomNum = rand.nextInt((max - min) + 1) + min;

 How to convert string to integer in java?

String str = “10”;
int output = Integer.parseInt(str);            //output is 10

Leave a Reply