Results 1 to 4 of 4
Thread: Unreachable statement
- 11-24-2010, 08:55 PM #1
Member
- Join Date
- Oct 2010
- Posts
- 80
- Rep Power
- 0
Unreachable statement
all i want to do is print the values returned by the method test. No matter where I put the system.out.print statement, the compiler "barks".
Everything I've read tells me that these errors will occur, BUT they do not tell me how to resolve the errors. (arrrrrrrrrggggggggghhhhhhhhh) I should taken quantum physics. Insanity would've overcome me sooner :mad:
Errors:Java Code:import java.util.*; import javax.swing.JOptionPane; public class Ex6e { public static void main(String[] args) { } public static int test (int x, char ch, double d, int y) { x = 5; ch = 'z'; d = 7.3; y=5; return (x); System.out.print(x); } }
Ex6e.java:16: unreachable statement
System.out.print(x);
^
Ex6e.java:18: missing return statement
}
- 11-24-2010, 09:28 PM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
in the line before , with return (x) you leave the method, so the System.out is unreachable!
change these two lines !
-
Once a method calls returns, the method ends. You've got a statement after the return that will never be called.
- 11-25-2010, 03:32 PM #4
Member
- Join Date
- Oct 2010
- Posts
- 80
- Rep Power
- 0
Similar Threads
-
Unreachable statement Pig Dice Game
By noturn10 in forum New To JavaReplies: 2Last Post: 11-22-2009, 12:36 AM -
The if Statement, need some help!
By Keno777 in forum New To JavaReplies: 6Last Post: 10-24-2009, 12:53 AM -
Unreachable Statement (accessors) - works as a main method!
By thomase in forum New To JavaReplies: 6Last Post: 03-11-2009, 04:38 PM -
unreachable statement - Java calculator program
By V2001Gordon in forum New To JavaReplies: 3Last Post: 12-13-2008, 12:57 AM -
Statement or Prepared Statement ?
By paty in forum JDBCReplies: 3Last Post: 08-01-2007, 04:45 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks