how can I make a java statement without using an IF statement?
June 29, 2009 - 9:29 pm
I need help writing a program that shows a specific numbers…there are 2 scenarios and I cant use an IF statement.
Any suggestions?
can you use a switch?
or you can simulate an if using the conditions of loops:
eg:
while(condition1 = true)
{
break;
}
while(condition 2 = true)
{
break;
}
June 30th, 2009 at 2:56 am
can you use a switch?
or you can simulate an if using the conditions of loops:
eg:
while(condition1 = true)
{
break;
}
while(condition 2 = true)
{
break;
}
References :
June 30th, 2009 at 3:46 am
Yeah u can use switch.
Otherwise use ternary operator.
<value_variable>=<condition>?:<true_statement>:<false_statement>
Let's say I want to display which number is bigger. The nos. are a and b.
int big;
big=a>b?a:b;
System.out.println("Bigger No. is "+big);
References :