• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

travel agent - java writing to file via user input  RSS feed

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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

 
Ranch Hand
Posts: 492
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.

 
Abhradeep Banerjee
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 492
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
im getting a out of memory heap error now all of a sudden anyone know the problem??
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One more request -- can you post a data file?
 
Abhradeep Banerjee
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
im getting a no element error now...


 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!