Search:

Type: Posts; User: dicdic

Search: Search took 0.50 seconds.

  1. Replies
    19
    Views
    288

    Re: 1 MINOR ERROR IN PROGRAM

    I think you assumed that you have 20 words in your file (separated by carriage return/enter).
    so read each line and store it in every element of your array.
    words[0] = first word of file.
    words[1]...
  2. Replies
    19
    Views
    288

    Re: 1 MINOR ERROR IN PROGRAM

    Oh I get it now. Here is what happened at back of your code:
    you declared a String array whose length is 20,
    so by default, all elements of your array is null (a null pointer).
    next you wrote...
  3. Replies
    19
    Views
    288

    Re: 1 MINOR ERROR IN PROGRAM

    Can you paste your updated code here?
    can you paste also the line 19 of your code? thanks.
  4. Replies
    19
    Views
    288

    Re: 1 MINOR ERROR IN PROGRAM

    because that is invalid syntax, that statement is attempting to put a value in specified index of array, but you did not provide any index on it.
    words[0] = in.nextLine(); 0 inside the bracket is...
  5. Replies
    19
    Views
    288

    Re: 1 MINOR ERROR IN PROGRAM

    at what part/line do get it? I'm sure it is saying a line number on which you got an error.
    is that really the error? because this line words [] = in.nextLine(); will make you have compilation error?
  6. Replies
    19
    Views
    288

    Re: 1 MINOR ERROR IN PROGRAM

    did you read it successfully? what is the problem now?
  7. Replies
    19
    Views
    288

    Re: 1 MINOR ERROR IN PROGRAM

    oh,, ArrayIndexOutOfBoundsException means that you attempted to access an element whose index is beyond the size.
    Index in array always starts with 0, and usually ends with the length - 1.

    so if...
  8. Replies
    19
    Views
    288

    Re: 1 MINOR ERROR IN PROGRAM

    look at this part of your code
    String words [1000]= new String " ";
    that is an invalid declaration of array as what Arrays (The Java™ Tutorials > Learning the Java Language > Language Basics) says,...
  9. Replies
    19
    Views
    288

    Re: 1 MINOR ERROR IN PROGRAM

    actually you a got a syntax error there. look at this code of yours:
    String [] words= new String [1000];
    Scanner in= new Scanner(new FileReader("list.txt"));
    [] words= in.nextLine();
    look at...
  10. Replies
    19
    Views
    288

    Re: 1 MINOR ERROR IN PROGRAM

    because you are passing an argument/parameter of type char, as StringBuilder (Java Platform SE 7 ) says, indexOf method accepts a String object, not a char primitive type.
    you better parse/convert...
Results 1 to 10 of 10