• Post Reply Bookmark Topic Watch Topic
  • New Topic

Trouble Writing Current Time to Text File  RSS feed

 
Anakela Bella
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there. I'm working on a project for class that asks me to record punch-in and punch-out times for employees. However, I am having difficulty figuring out where I am going wrong as none of the information will write to the text file in the ArrayList that I have created. The code is as follows:

I want to keep the coding as simple as possible as I am new to Java, and have spent hours upon hours trying to figure this all out. If it helps, the console output looks like this:

Thank you in advance for your help!
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are declaring and initializing an ArrayList timeClock in line 19, but you're never putting anything in the ArrayList.

When you try to save the content of the ArrayList, it's empty, so nothing is saved.

In the two while-loops in lines 39-49 and 50-61 you're printing information to the screen, but nothing is ever stored in the ArrayList.
 
sreenivasarao mydukuri
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:You are declaring and initializing an ArrayList timeClock in line 19, but you're never putting anything in the ArrayList.

When you try to save the content of the ArrayList, it's empty, so nothing is saved.

In the two while-loops in lines 39-49 and 50-61 you're printing information to the screen, but nothing is ever stored in the ArrayList.


yes you are correct he did the above mistakes only ,

i added sample code for that please observe..............................



 
Campbell Ritchie
Marshal
Posts: 56581
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use the code button because otherwise you lose the formatting and the code becomes illegible. I'll edit your post this once, and you can see how much better it looks
 
Anakela Bella
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sreenivasarao mydukuri wrote:
Jesper de Jong wrote:You are declaring and initializing an ArrayList timeClock in line 19, but you're never putting anything in the ArrayList.

When you try to save the content of the ArrayList, it's empty, so nothing is saved.

In the two while-loops in lines 39-49 and 50-61 you're printing information to the screen, but nothing is ever stored in the ArrayList.


yes you are correct he did the above mistakes only ,

i added sample code for that please observe..............................




Yes, that was the problem. Thank you for your help! If I also wanted to record what the user is typing in (like the i/o and their employee number), would I do something like this?:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!