Results 1 to 7 of 7
Thread: Eclipse won't run program?
- 10-21-2012, 09:32 PM #1
Member
- Join Date
- Sep 2012
- Posts
- 17
- Rep Power
- 0
Eclipse won't run program?
This is just a thing I made for my friend who doesn't know what WoW character to play on.
I don't get any errors, here is the code
Java Code:import java.util.Random; import java.util.Scanner; class apples { public static void main(String args[]){ Random dice = new Random(); Scanner input = new Scanner(System.in); int numberofclasses; numberofclasses=input.nextInt(); System.out.print("Number of classes is" +numberofclasses); String classes[]= new String[numberofclasses]; for(int count=0; count<classes.length; count++){ System.out.println("Type class number" + count); classes[count]=input.nextLine(); System.out.println(classes[count]); } int number=dice.nextInt(); number=number%classes.length; System.out.println(classes[number]); } }
- 10-22-2012, 10:35 PM #2
Member
- Join Date
- Sep 2012
- Posts
- 11
- Rep Power
- 0
Re: Eclipse won't run program?
it's obvious you can't use a variable as an array delimiter, it need to be a constant so this is fail :
try it this wayJava Code:int numberofclasses; numberofclasses=input.nextInt();
Java Code:final int numberofclasses =10;//whatever you want
- 10-23-2012, 03:42 PM #3
- 10-23-2012, 03:43 PM #4
- 10-24-2012, 01:11 PM #5
Member
- Join Date
- Sep 2012
- Posts
- 17
- Rep Power
- 0
Re: Eclipse won't run program?
When i click 'run,' nothing happens, but there are no errors in the code, or at least none that eclipse shows me
- 10-24-2012, 01:53 PM #6
Re: Eclipse won't run program?
Stick a System.out.println(...) right at the top of your main(...) method, between lines 4 and 5 of your posted code, and see if that prints. Report back here.
Also, go through Code Conventions for the Java Programming Language: Contents -- a class name should start with an uppercase letter.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 10-25-2012, 12:00 AM #7
Senior Member
- Join Date
- Oct 2012
- Posts
- 108
- Rep Power
- 0
Similar Threads
-
Program running in eclipse but JAR won't run?
By Jma84 in forum New To JavaReplies: 4Last Post: 08-13-2012, 11:52 AM -
Need help with java program using eclipse
By starplayerrob in forum New To JavaReplies: 16Last Post: 07-01-2011, 09:34 AM -
I cant run the program outside eclipse, why?
By kokorini in forum New To JavaReplies: 4Last Post: 07-02-2010, 10:46 PM -
A tab in an eclipse RCP program
By Drun in forum EclipseReplies: 0Last Post: 05-20-2010, 03:56 PM -
DB program in Eclipse
By Unni in forum EclipseReplies: 3Last Post: 08-09-2007, 11:07 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks