| Author |
travel agent - java writing to file via user input
|
Abhradeep Banerjee
Ranch Hand
Joined: Dec 09, 2009
Posts: 71
|
|
1)getting error at line 78 lab6Ex1
2) how do i delete a record via user input eg. if user wants to delete record 0 the user will enter the number 0 and it will delete 0
i know its LL.remove();
im not sure what to put inside the bracket
Travel.java
|
 |
Hunter McMillen
Ranch Hand
Joined: Mar 13, 2009
Posts: 490
|
|
Abhradeep Banerjee wrote:
1)getting error at line 78 lab6Ex1
What error are you getting exactly?
Abhradeep Banerjee wrote:
2) how do i delete a record via user input eg. if user wants to delete record 0 the user will enter the number 0 and it will delete 0
i know its LL.remove();
im not sure what to put inside the bracket
You are using a linkedlist so elements in the list arent indexed with numbers like an array. You would have to write your own function to go n elements into the list and remove that element.
|
"If the facts don't fit the theory, get new facts" --Albert Einstein
|
 |
Abhradeep Banerjee
Ranch Hand
Joined: Dec 09, 2009
Posts: 71
|
|
1) yes i know its not in array but if im not wrong you can just use the remove command and delete the record via index which Ihave declared
2)
Exception in thread "main" java.util.NoSuchElementException
at java.util.StringTokenizer.nextToken(StringTokenizer.java:332)
at lab6Ex1.main(lab6Ex1.java:78)
Java Result: 1
|
 |
Hunter McMillen
Ranch Hand
Joined: Mar 13, 2009
Posts: 490
|
|
Ok so the error you are getting if from calling nextToken() the NoSuchElementException comes from not having anything in the Tokenizer. You can't get the next token of an empty tokenizer. So I would print out your line variable to check to see if what you think is there, is actually there.
You are correct about the remove function , I didn't know it had that capability.
Hunter
|
 |
Abhradeep Banerjee
Ranch Hand
Joined: Dec 09, 2009
Posts: 71
|
|
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOfRange(Arrays.java:3209)
at java.lang.String.<init>(String.java:215)
at java.io.BufferedReader.readLine(BufferedReader.java:331)
at java.io.BufferedReader.readLine(BufferedReader.java:362)
at lab6Ex1.main(lab6Ex1.java:91)
Java Result: 1
BUILD SUCCESSFUL (total time: 14 seconds)
getting this error now
|
 |
Abhradeep Banerjee
Ranch Hand
Joined: Dec 09, 2009
Posts: 71
|
|
|
im getting a out of memory heap error now all of a sudden anyone know the problem??
|
 |
pete stein
Bartender
Joined: Feb 23, 2007
Posts: 1561
|
|
|
Please show what your code now looks like and which line (mark with an obvious comment such as // !!! error here !!!) causes the exception. I see one while loop where you check to see if line is null but you don't appear to ever change the state of the line variable.
|
 |
Abhradeep Banerjee
Ranch Hand
Joined: Dec 09, 2009
Posts: 71
|
|
|
|
 |
pete stein
Bartender
Joined: Feb 23, 2007
Posts: 1561
|
|
|
One more request -- can you post a data file?
|
 |
Abhradeep Banerjee
Ranch Hand
Joined: Dec 09, 2009
Posts: 71
|
|
|
i found the problem the code for insert had a problem instead of adding just 1ce it added it multiple times
|
 |
Abhradeep Banerjee
Ranch Hand
Joined: Dec 09, 2009
Posts: 71
|
|
|
|
 |
pete stein
Bartender
Joined: Feb 23, 2007
Posts: 1561
|
|
Abhradeep Banerjee wrote:i found the problem the code for insert had a problem instead of adding just 1ce it added it multiple times
Good deal -- congratulations!
|
 |
Abhradeep Banerjee
Ranch Hand
Joined: Dec 09, 2009
Posts: 71
|
|
im getting a no element error now...
|
 |
 |
|
|
subject: travel agent - java writing to file via user input
|
|
|