Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: GUI Lotto Program Not Compiling

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default GUI Lotto Program Not Compiling

    Hey guys, so, I'm creating a GUI Lotto Game for my friend. However, when it comes to compiling the non-GUI part of it, it gives me an error on lines 8 and 10.

    The error message is:

    "Invalid argument to operation ++/--"

    Here is my code:

    "
    class Random
    {
    public static void main (String[] args)

    {
    int[] nums = new int[50];
    for(int i = 1; i < 50; 1++) { nums[i] = i; }

    for(int i = 1; i < 50; 1++)

    {
    int r = (int) Math.ceil(Math.random() * 49);
    int temp=nums[i];
    nums[i]=nums[r];
    nums[r]=temp;
    }

    for (int i = 1; 1 < 7; i++)
    {
    System.out.print(Integer.toString(nums[i]) + " ");
    }
    }
    }
    "

    The code on the lines receiving the error is:

    "for(int i = 1; i < 50; 1++)"

    If it helps, I'm doing this in Java 6!

    Thanks,
    FalcomerG


  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,697
    Thanks
    25
    Thanked 334 Times in 310 Posts

    Default Re: GUI Lotto Program Not Compiling

    for(int i = 1; i < 50; 1++) { nums[i] = i; }

    for(int i = 1; i < 50; 1++)

    I think you mean those to be i++ not 1++
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  3. #3
    Junior Member
    Join Date
    Dec 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: GUI Lotto Program Not Compiling

    Haha. Yes. Thanks! I knew it looked weird

    --- Update ---

    A little off topic, but do you know why I can't make anything a runnable java file from eclipse?

  4. #4
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,697
    Thanks
    25
    Thanked 334 Times in 310 Posts

    Default Re: GUI Lotto Program Not Compiling

    .java files are not executable, they are just source files. .class files are compiled java files, which can be ran from the command line. However, if you want a file you can double-click and run, you need to create a .jar.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

Similar Threads

  1. [SOLVED] Program not compiling correctly
    By d0mlnance in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 1st, 2013, 10:53 AM
  2. Replies: 0
    Last Post: March 1st, 2013, 08:13 PM
  3. Lotto program for intro to programing final
    By dozindave in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 28th, 2012, 10:08 PM
  4. program not compiling
    By russ in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 26th, 2012, 12:39 AM
  5. new program (lotto.class)
    By james137 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: November 3rd, 2009, 05:22 PM