How can I compare two integers properly?

0 votes
Hey, I am not able to compare two integers properly. Can you please help with the code snippet.
May 31 in Java by Divya
33 views

1 answer to this question.

0 votes

Hi Divya,

I hope this code snippet will help you out.

public class Main

{

public static void main(String[] args) {

int x=10;

int y=10;


if(x==y){

     System.out.println("yes");

}

else

{

     System.out.println("No");

}

}

}

Thank you,

answered May 31 by sampriti
• 1,100 points

Related Questions In Java

0 votes
1 answer

How can I calculate number of days between two dates?

You may refer this. This might work ...READ MORE

answered Jul 19, 2018 in Java by Akrati
• 3,150 points
261 views
0 votes
2 answers

How can I convert a String variable to a primitive int in Java

 Here are two ways illustrating this: Integer x ...READ MORE

answered Aug 20 in Java by Sirajul
• 31,980 points
170 views
0 votes
2 answers

How can I create File and write data in it using Java?

import java.io.BufferedWriter; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; public class WriteFiles{ ...READ MORE

answered Jul 26, 2018 in Java by samarth295
• 2,190 points
108 views
0 votes
1 answer

I am learning looping statements. Can you tell me how 'for-each' works in Java?

While programming we often write code that ...READ MORE

answered Apr 17, 2018 in Java by Rishabh
• 3,540 points
57 views
0 votes
1 answer

Are arrays equivalent to objects in Java ?

Yes; the Java Language Specification writes: In the Java ...READ MORE

answered May 10, 2018 in Java by Rishabh
• 3,540 points
69 views
0 votes
1 answer

Remove objects from an array in Java?

We can use external libraries: org.apache.commons.lang.ArrayUtils.remove(java.lang.Object[] array, int ...READ MORE

answered Jun 26, 2018 in Java by scarlett
• 1,280 points
58 views
0 votes
1 answer

Performance difference of if/else vs switch statement in Java

The thing you are worried about is ...READ MORE

answered Jul 26, 2018 in Java by geek.erkami
• 2,640 points
482 views
+1 vote
3 answers

What is the syntax to declare and initialize an array in java?

You can use this method: String[] strs = ...READ MORE

answered Jul 25, 2018 in Java by samarth295
• 2,190 points
473 views
0 votes
1 answer

How can I make my output float when my two integers are integer?

Hi Prapti , I got your doubt please check ...READ MORE

answered Jun 3 in Java by sampriti
• 1,100 points
32 views
0 votes
1 answer

how to compare two words in java?

hey,  I think in your code the function ...READ MORE

answered Aug 7 in Java by sampriti
• 1,100 points

edited Aug 8 by Kalgi 259 views