This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 3411
    
  12
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
 
Similar Threads
org.mule.routing.filters.xml.JXPathFilter filter not working for me
Does String Object are actually of Immutable type ?
Cursors in a procedure
threads
while(true)