Relative Content

Tag Archive for javavariablesiterationuser-input

Creating iterative variables through a loop

So I am new to java (previously learnt python,jss,html and css) and have recently moved on to learning Classes and Objects.
I am making a book library as a practise exercise and want to get the user to input data for the book using scanner I will display the code I have done so far. I am aware i do not have a while loop in place but i would like to sort the code out for adding 1 book before i do that. Currently i am stuck on how to iterate through and add multiple books for example if the user choses to add a book i am assuming it should add books like book1name= Booklist.name and for when the user wants to add another book im assuming it should be book2name= Booklist.name. However i am struggling on how to iterate through this (change it from book1name to book2name automatically) and how to change the variable name while the code is running. I know i might have messed up the explination but hopefully you more experienced programmers can understand what i am getting at.