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
18 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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
• 620 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
162 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,310 points
63 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
55 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
35 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
39 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
28 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
242 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
149 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
• 620 points
16 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
• 620 points
14 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.