Do you mean likeee if the user types something in, the program records the information into a variable?
If thats the case you can do it very very easily, and even have constructors through the means of empty variables.
For example
Int a = 0;
Scanner keyboard = new Scanner (System.in);
System.out.println("Type your favorite number");
a = keyboard.nextInt;
System.out.println("Your favorite number is" + a );
I actually have no idea what you need help with so all this information is very generic.
Try reading this code, its what I use almost every time I want to implement reading from a text file
Code:
import java.io.*;
public class ReadFile {
public static void main(String[] args){
String string="";
String file ="textFile.txt";
//reading
try{
InputStream ips=new FileInputStream(fichier);
InputStreamReader ipsr=new InputStreamReader(ips);
BufferedReader br=new BufferedReader(ipsr);
String line;
while ((ligne=br.readLine())!=null){
System.out.println(line);
string+=line+"\n";
}
br.close();
}
catch (Exception e){
System.out.println(e.toString());
}
//writing
try {
FileWriter fw = new FileWriter (file);
BufferedWriter bw = new BufferedWriter (fw);
PrintWriter fileOut = new PrintWriter (bw);
fileOut.println (string+"\n test of read and write !!");
fileOut.close();
System.out.println("the file " + file + " is created!");
}
catch (Exception e){
System.out.println(e.toString());
}
}
}