Home > Back-end >  Arraylist array encounter problems, learn from each elder??
Arraylist array encounter problems, learn from each elder??

Time:12-10

Written in a class, give a Arraylist array assignment, now judge enter 1 time to modify the subscript 2 elements, but can not change, the set error is how to return a responsibility?

CodePudding user response:

ArrayList type is a test, the set of "dsaf" is a String type,
 public String STR; 

.

The test m1=new test ();
M1. STR="dsaf";
L.s et (2, m1);

CodePudding user response:

You directly to collection set a String must not ah, want to take the test first, and then to the second attribute assignment,

CodePudding user response:

Such deposit l.s et (new test (2, "dsaf"));

CodePudding user response:

reference 3 floor yuan dream people reply:
such deposit l.s et (new test (2, "dsaf"));

Ok, thank you!

CodePudding user response:

reference 1/f your 燚 龘 response:
ArrayList type is a test, the set of "dsaf" is a String type,
 public String STR; 

.

The test m1=new test ();
M1. STR="dsaf";
L.s et (2, m1);


Ok, thank you!

CodePudding user response:

reference 4 floor weixin_47184967 response:
Quote: reference 3 floor yuan dream people reply:
so save l.s et (new test (2, "dsaf"));

Ok, thank you!
however, so you have to add the full constructor, don't know the constructor did you learn?

CodePudding user response:

reference floor 6 yuan dream people reply:
Quote: refer to 4th floor weixin_47184967 response:
Quote: refer to the third floor yuan dream people reply:
this deposit l.s et (new test (2, "dsaf"));

Ok, thank you!
however, so you have to add the full constructor, don't know the constructor did you learn?

Haven't learn yet

CodePudding user response:

reference floor 6 yuan dream people reply:
Quote: refer to 4th floor weixin_47184967 response:
Quote: refer to the third floor yuan dream people reply:
this deposit l.s et (new test (2, "dsaf"));

Ok, thank you!
however, so you have to add the full constructor, don't know the constructor did you learn?

Constructor how ah?

CodePudding user response:

The public test (int num, String STR) {
This. Num=num;
Enclosing the STR=STR;
}

CodePudding user response:

You specify what type, save is corresponding to the type
  • Related