Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2012
    Rep Power

    Default No syntax errors, but run-time error exists?

    public class DigitExtractor {
    private String digits;
    private String array;
    public DigitExtractor()
    public DigitExtractor(String digits)
    public String extract()
    int diglength=digits.length();
    for(int i = 0;i<(diglength-1);i++)
    return array;


    import java.util.Scanner;
    public class DigitExtractorTester {
    private static Scanner inputstring;

    public static void main(String[] args)
    System.out.println("type in #");
    inputstring=new Scanner(;
    String digits=inputstring.toString();
    DigitExtractor derp=new DigitExtractor(digits);



    I expected the scanner to start, but it did not.
    The console displayed:

    type in # //from the System.out.println in the tester program

    What does the "E]" mean?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power

    Default Re: No syntax errors, but run-time error exists?

    Java Code:
    String digits=inputstring.toString();
    You're getting the toString() representation of a Scanner object, which is not what you want and which is not how you use a Scanner object.
    You may want to read the API entry for this or the tutorial. For my money, I'd use its nextLine() method. Also your extract() method doesn't make much sense to me.

    It's a good lesson though: lack of syntax errors will only get you so far. The program still must make logical sense.

Similar Threads

  1. Syntax Errors
    By andimiami in forum New To Java
    Replies: 8
    Last Post: 09-15-2011, 02:23 PM
  2. ClassNotFoundException error for a class that exists
    By dahaka2011 in forum Sun Java Wireless Toolkit
    Replies: 1
    Last Post: 04-01-2011, 03:44 AM
  3. Eclipse is making me go silly with it's syntax errors
    By magicmojo in forum New To Java
    Replies: 5
    Last Post: 02-22-2011, 02:48 PM
  4. Run time errors
    By crabman in forum New To Java
    Replies: 6
    Last Post: 10-11-2009, 10:51 PM
  5. Cannot get passed these syntax errors
    By MrKP in forum New To Java
    Replies: 1
    Last Post: 05-12-2008, 08:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts