Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package dynamicList;
- import java.util.ArrayList;
- public class listAppend {
- protected String username;
- protected String password;
- public listAppend(String username, String password) {
- username = this.username;
- password = this.password;
- //My goal was to use append the password parameter of every object created, but null kept coming back as value.
- //usernameList.add(this.password);
- }
- //Instead I tried invoking method on specific objects statically after instantiation and it was still null value.
- public void addPass() {
- usernameList.add(this.password);
- }
- static ArrayList<String> usernameList = new ArrayList<String>();
- public String getusername() {
- return username;
- }
- //Just a test to see if password wouldn't print null anymore.
- public void printing() {
- System.out.print(password);
- }
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- //creating object with arguments to be stored as values, right?
- listAppend Kelly = new listAppend("Kelly", "12321");
- System.out.println(Kelly.password);
- Kelly.addPass();
- System.out.println(usernameList);
- //Only going through and assigning it statically seemed to return value as desired.
- //Kelly.password = "920928";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement