Results 1 to 10 of 10
Thread: Java Syntax If statement
- 09-01-2010, 09:08 AM #1
Member
- Join Date
- Aug 2010
- Posts
- 16
- Rep Power
- 0
- 09-01-2010, 09:17 AM #2
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 697
- Rep Power
- 6
- 09-01-2010, 09:30 AM #3
Member
- Join Date
- Aug 2010
- Posts
- 16
- Rep Power
- 0
my "this" and "that" are very long and i can't go over the 80 character width so it effectively adds unnecessary lines to my code.
I tried if(a==(this||that)) but it didnt work.
- 09-01-2010, 09:37 AM #4
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 697
- Rep Power
- 6
You can always refactor your very long "this" and "that" expression into methods which you can call from the if statement.
Last edited by wsaryada; 09-01-2010 at 10:14 AM.
Website: Learn Java by Examples
- 09-01-2010, 10:08 AM #5
Member
- Join Date
- Aug 2010
- Posts
- 16
- Rep Power
- 0
Ok thanks for that. Now a totally different question.
How can i catch a ArithmeticException, i try
catch(ArithmeticException)
but it doesnt recognise ArithmeticException.
- 09-01-2010, 11:31 AM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
What do you mean by "doesn't recognise".
When you get exceptions or compilation errors you really need to post the exact error you are getting.
- 09-01-2010, 11:52 AM #7
Member
- Join Date
- Aug 2010
- Posts
- 16
- Rep Power
- 0
Sorry i figured it out, I wasnt using try {}, and also i didnt put an identifier after the arithmeticexception,
eg. ArithmeticException e
- 09-01-2010, 12:11 PM #8
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
But that's not really mean "dosen't recognize". If you have a look at your error message then you can find the most suitable word for that. Try to stick with them. :)
- 09-01-2010, 12:14 PM #9
Member
- Join Date
- Aug 2010
- Posts
- 16
- Rep Power
- 0
Sorry about that, the proper error was "ArithmeticException cannot be resolved".
All good now though :)
- 09-01-2010, 12:21 PM #10
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Similar Threads
-
Specific syntax? java.util.regex.Pattern$Node
By lmhelp2 in forum New To JavaReplies: 1Last Post: 04-09-2010, 11:32 AM -
Java syntax I don't understand - assignment
By poet in forum New To JavaReplies: 2Last Post: 09-19-2009, 06:47 AM -
Java JDBC/MySQL appropriate Syntax
By thelinuxguy in forum Advanced JavaReplies: 7Last Post: 02-10-2009, 07:57 PM -
Java Syntax for making 2 divs same height dynamically.
By jatrant in forum New To JavaReplies: 4Last Post: 06-25-2008, 08:09 PM -
JavaScript to Java Statement
By mutuah in forum Advanced JavaReplies: 0Last Post: 08-08-2007, 05:16 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks