cancel
Showing results for 
Search instead for 
Did you mean: 

Very simple question - If statement

Former Member
0 Kudos

Hi Experts,

I have to write following logic in form of Java statement. How I can do so?

If condition 1 (value = 1)

do..

If condition 2 (value = 2)

do..

If condition 3 (all values other than 1 and 2)

do..

How I can write Java statement for above?

Regards,

Gary

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Use switch/case : [The switch Statement|http://java.sun.com/docs/books/tutorial/java/nutsandbolts/switch.html].

EDIT : or you can use if-then-else for non primitive data types : [The if-then and if-then-else Statements|http://java.sun.com/docs/books/tutorial/java/nutsandbolts/if.html].

Regards,

Pierre

Edited by: Pierre DOMINIQUE on Aug 25, 2009 10:05 AM

Answers (0)