I have a string idnum. I add a value to that string using the code below. The function show() displays the value of the string in the console. I wish to have a function that can edit the value of string idnum in the console, without having to exit the console. How do I do that? I am thinking of overwriting the value of the string. Is that possible? How do I overwrite the value of a string in the console?
public void addstudent(){
student p = null;
reader1 = new BufferedReader(new InputStreamReader(System.in));
System.out.print("ID Number: ");
String idnum = null;
try {
idnum = reader1.readLine();
}
catch (IOException e){
e.printStackTrace();
}
p = new student(idnum);
studentList.add(p);
show();
}
I have this code for the search part
public void searchstudent(){
System.out.print("search name : ");
try{ searchName = reader1.readLine();} catch (IOException e){e.printStackTrace();}
searchCount = 0;//for search
for(int i = 0; i<count; i++){
if(studentList.get(i).getLName().toLowerCase().contains(searchName.toLowerCase())){
searchCount = i;
System.out.println(studentList.get(searchCount).getLName());
}
}
}