aspose file tools*
The moose likes Beginning Java and the fly likes How Can I do it without using if condition Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How Can I do it without using if condition" Watch "How Can I do it without using if condition" New topic
Author

How Can I do it without using if condition

Bhairava Surya
Ranch Hand

Joined: Aug 19, 2007
Posts: 45
Hi All,

Consider a program accepts inputs like '4', or some string etc.

Using exceptions concept how can i display whether the input is number or string.. without using 'if condition'??

Thanks & Regards,
Ravi.
S. Nitesh
Ranch Hand

Joined: Jan 15, 2010
Posts: 36
    
    1


I think, this should work.
Bhairava Surya
Ranch Hand

Joined: Aug 19, 2007
Posts: 45
Hi Nitesh,

Thanks for your immediate reply. But, can you give a complete code without if condition.
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3553
    
  15
Which bit are you having a problem with ? Put that line of code in a try/catch block, add a couple of print statements and you're done. Give it a try. You'll learn more by trying it yourself than having the code given to you.


Joanne
S. Nitesh
Ranch Hand

Joined: Jan 15, 2010
Posts: 36
    
    1

Chinna,
Did you work on Joanne's suggestion?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How Can I do it without using if condition