Results 1 to 2 of 2
  1. #1
    Azndaddy is offline Member
    Join Date
    Mar 2008
    Posts
    24
    Rep Power
    0

    Default [SOLVED] Line number: ?

    Hi, just having a problem at the moment with my code. its only part of the code from the class

    PHP Code:
        public void execute()
        {
            buffer = new Buffer();
            System.out.print("Line number: ");
            int pos = Integer.parseInt(getInput());
            buffer = editor.getCurrentBuffer();
            System.out.println(pos +": " +buffer.getLines().get(pos-1));
            buffer.setPos(pos-1);
            editor.setCurrentBuffer(buffer);
        }
    What im trying to do is, when i type in the command goto, it will print the line number in which i chose. example when i type goto, then press 3, it will print out line numbeer 3. but the problem im having is, when i type in goto, 0 which is the line number, it gives me an error.

    how could i fix this so that when i type goto, 0 line, it print out the following
    Line number: ?

    Thanks

  2. #2
    Azndaddy is offline Member
    Join Date
    Mar 2008
    Posts
    24
    Rep Power
    0

    Default

    nvm

    Fixed it

    added the following line

    PHP Code:
    if(getCurrentBuffer().getPos() == 0)
    
    else
    
    System.out.println("Line Number: ?");

Similar Threads

  1. [SOLVED] Delete Current line from file
    By Azndaddy in forum New To Java
    Replies: 2
    Last Post: 04-06-2012, 08:00 AM
  2. [SOLVED] Last line in JTextArea wont display
    By Chris.Brown.SPE in forum Advanced Java
    Replies: 5
    Last Post: 04-11-2008, 01:52 PM
  3. line number
    By kazitula in forum New To Java
    Replies: 3
    Last Post: 11-21-2007, 10:27 PM
  4. Reading in data from file line by line
    By bluekswing in forum New To Java
    Replies: 1
    Last Post: 10-02-2007, 12:19 AM
  5. how to know the number of the line
    By simon in forum New To Java
    Replies: 3
    Last Post: 08-01-2007, 04:59 PM

Posting Permissions

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