Results 1 to 5 of 5
Thread: Finding bug and correcting it
- 12-06-2012, 04:26 AM #1
Member
- Join Date
- Oct 2012
- Posts
- 30
- Rep Power
- 0
- 12-06-2012, 04:33 AM #2
Senior Member
- Join Date
- Nov 2012
- Posts
- 105
- Rep Power
- 0
Re: Finding bug and correcting it
Press the compile button?
- 12-06-2012, 04:48 AM #3
Member
- Join Date
- Oct 2012
- Posts
- 30
- Rep Power
- 0
Re: Finding bug and correcting it
I can't run it. My professor just gave me that piece of code and said to find the bug. If I can run it I'll be able to figure it maybe but I don't know how to make the class so i can run it. I have something like this
But it says illegal start of expression on the line where public void bug(int a, int b) is located.Java Code:public class bug { public static void main(String[] args) { public void bug(int a, int b) { int first = a ; int second = b; int temp = 0; if (a>b) { temp = a; first = b; second = a; } System.err.println(first + "" + second) ; } }
What is actually meant by print the larger number first?
- 12-06-2012, 06:49 AM #4
Senior Member
- Join Date
- Nov 2012
- Posts
- 105
- Rep Power
- 0
Re: Finding bug and correcting it
Methods can't be inside other methods.
- 12-06-2012, 09:58 AM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Similar Threads
-
Having trouble correcting this code.
By Denis2k11 in forum New To JavaReplies: 7Last Post: 10-14-2012, 01:13 AM -
Finding the Median
By system5634 in forum New To JavaReplies: 1Last Post: 02-07-2012, 01:30 PM -
finding max value
By rocky86 in forum New To JavaReplies: 6Last Post: 10-10-2010, 01:37 AM -
Need help correcting - Newbie don't know what's wrong
By Pokora in forum New To JavaReplies: 3Last Post: 02-22-2010, 04:20 AM -
Finding where to draw
By flok in forum AWT / SwingReplies: 4Last Post: 11-24-2009, 05:55 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks