Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Super simple problem with ArrayList in Java
- public class Cliente {
- private static String user;
- private static String password;
- public Cliente (String usr, String pass) {
- user = usr;
- password = pass;
- }
- public String getUser() {
- return user;
- }
- }
- public class AddToArrayList{
- static ArrayList<Cliente> listaClientes = new ArrayList<Cliente>();
- public static void main(String[] args) throws IOException {
- Cliente c1 = new Cliente("pepe","pepe1");
- Cliente c2 = new Cliente("jose","jose1");
- Cliente c3 = new Cliente("edu","edu1");
- listaClientes.add(c1);
- listaClientes.add(c2);
- listaClientes.add(c3);
- printArraList();
- }
- public static void printArraList() throws IOException {
- for (Cliente c : listaClientes) {
- System.out.println(c.getUser());
- }
- }
- private static String user;
- private static String password;
- private String user;
- private String password;
Add Comment
Please, Sign In to add comment