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
21 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
• 860 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
175 views
0 votes
1 answer

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

You can convert a String to int by using a function: int ...READ MORE

answered Apr 12, 2018 in Java by sharth
• 3,320 points
83 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
62 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,520 points
39 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,520 points
42 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
32 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,320 points
279 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
191 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
• 860 points
23 views
0 votes
1 answer

How to Iterate HashMap?

Hi Shashank. Please try this code I hope ...READ MORE

answered May 30 in Java by Sampriti
• 860 points
18 views