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: For loop error

  1. #1
    Junior Member
    Join Date
    Jun 2014
    Posts
    9
    My Mood
    Dead
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default For loop error

    I'm working on a program and can't seem to fix my for loop error here is my code please help
    I get an error at the for loop line saying illegal start of expression and i don't know how to fix it:
    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
     
    package million;
    import java.util.Scanner;
     
     
     
    /**
     *
     * @author Aosora
     */
    public class Million {
     
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            // TODO code application logic here
            int NoCus = 0;
            getCustomers(NoCus);
        }
     
      public static void getCustomers(int NoCus){
          Scanner sc = new Scanner(System.in);
          System.out.println("Enter the number of customers");
          NoCus = sc.nextInt();
          System.out.println("Number of customers entered  = "+NoCus);
          getDetails(NoCus);
          }//end GetCustomers
     
      public static void getDetails(int NoCus){
          for(int proCus = 0; proCus !== NoCus; proCus++){
     
          }
      }
     
    }//end main


  2. #2
    Junior Member
    Join Date
    Jun 2014
    Posts
    22
    My Mood
    Starving
    Thanks
    1
    Thanked 8 Times in 6 Posts

    Default Re: For loop error

    You have an extra "=" in the for loop. Should be "!=" not "!=="


    Here is the Java Docs for Operators: http://docs.oracle.com/javase/tutori...operators.html
    Last edited by koder632417; June 3rd, 2014 at 10:33 PM.

  3. The Following User Says Thank You to koder632417 For This Useful Post:

    Ada Lovelace (June 4th, 2014)

  4. #3
    Junior Member
    Join Date
    Jun 2014
    Posts
    9
    My Mood
    Dead
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: For loop error

    Thank you koder632417 i just thought since "=" means assignment and "==" meant evaluating equality then "!==" would be not equal anyways thanks a million

  5. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: For loop error

    There are textbooks and documents online that explain these language details that you can use as handy references rather than guessing.

Similar Threads

  1. Loop error
    By skypi205 in forum Java Theory & Questions
    Replies: 1
    Last Post: November 3rd, 2013, 05:32 AM
  2. [SOLVED] error with equals in arraylist loop
    By Randor in forum Loops & Control Statements
    Replies: 2
    Last Post: November 27th, 2012, 10:46 AM
  3. [SOLVED] Simple Increment in a Loop error
    By chrisob in forum Loops & Control Statements
    Replies: 7
    Last Post: May 22nd, 2012, 07:33 AM
  4. Possible Loop Error...
    By The_Mexican in forum What's Wrong With My Code?
    Replies: 10
    Last Post: December 5th, 2010, 03:17 PM
  5. Error when loop used
    By anandkokatnur in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 24th, 2010, 11:17 AM