Error message - Java

This is a discussion on Error message - Java ; Hi I am having problems with my code. It is given me an error message stating "cannot find symbol variable NotCont" on line 26. 1-import java.util.Scanner; 2-public class IntegerSetTest 3-{ 4- public static void main(String[] args) 5- { 6- Scanner ...

+ Reply to Thread
Results 1 to 3 of 3

Error message

  1. Default Error message

    Hi I am having problems with my code.
    It is given me an error message stating "cannot find symbol variable
    NotCont" on line 26.

    1-import java.util.Scanner;
    2-public class IntegerSetTest
    3-{
    4- public static void main(String[] args)
    5- {
    6- Scanner input = new Scanner (System.in);
    7-
    8- System.out.println("Welcome to the Integer Set\n");
    9-
    10- System.out.println("This program is going to find the union "
    +
    11- " or intersection of any two sets you enter" +
    12- "\nPlease enter the number of sets: ");
    13- int intArray[] = new int[100];
    14- int value;
    15- try
    16- {
    17- do
    18- {
    19- int i;
    20-
    21- value = input.nextInt();
    22- intArray[i]=value;
    23- System.out.println("Enter -1 to end: ");
    24- int NotCont = input.nextInt();
    25- i++;
    26- }while(NotCont != -1);
    27-
    28- for(int i=0; i<intArray.length;i++)
    29- {
    30- System.out.println(intArray[i]);
    31- }
    32- }
    33- catch(NumberFormatException ex)
    34- {
    35- }
    36- }
    37-}


  2. Default Re: Error message

    On Wed, 17 Oct 2007 19:37:03 -0700, sdlt85@gmail.com wrote, quoted or
    indirectly quoted someone who said :

    >{
    >19- int i;
    >20-
    >21- value = input.nextInt();
    >22- intArray[i]=value;
    >23- System.out.println("Enter -1 to end: ");
    >24- int NotCont = input.nextInt();
    >25- i++;
    >26- }while(NotCont != -1);



    1. NotCont shoud start with a lower case letter since it is a local
    variable. See http://mindprod.com/jgloss/codingconventions.html

    2. NotCont is declared inside the while block. It is not known
    outside the block. You need to move the declaration to a block
    enclosing all its usages.

    --
    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com

  3. Default Re: Error message

    On Wed, 17 Oct 2007 19:37:03 -0700, sdlt85@gmail.com wrote, quoted or
    indirectly quoted someone who said :

    >Hi I am having problems with my code.
    >It is given me an error message stating "cannot find symbol variable
    >NotCont" on line 26.


    First thing to try in that situation is to look up the error message.

    http://mindprod.com/jgloss/compileer...NNOTFINDSYMBOL

    The clues as to what it means and what causes it are often sufficient.
    --
    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com

+ Reply to Thread

Similar Threads

  1. Replies: 0
    Last Post: 02-14-2007, 10:04 AM
  2. Replies: 0
    Last Post: 02-14-2007, 09:13 AM
  3. Replies: 0
    Last Post: 02-14-2007, 05:42 AM
  4. Replies: 2
    Last Post: 08-03-2006, 08:54 AM
  5. Replies: 3
    Last Post: 01-21-2005, 10:14 AM