Answer the question
In order to leave comments, you need to log in
How to write java class to dat file?
Let's say I have a USER class
public class User {
private String name;
private int age;
public User (String name, int age) {
this.name = name;
this.age = age;
}
public String toString () {
return "Name: " + name + " age: " + age;
}
}
public class Main {
public static void main (String [] args) {
List <User> UserList = new ArrayList <> ();
UserList.add(new User ("Example", 1));
UserList.add(new User ("Example", 2));
UserList.add(new User ("Example", 3));
}
}
Answer the question
In order to leave comments, you need to log in
Google serialization. You can use Serializable, or json, xml. A million options.
The question still remains: Why would someone help you if you don't accept answers?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question