Home > Back-end >  Code optimization!!!!!! Who can look at the use the get (int index) and set (int index, Object obj)
Code optimization!!!!!! Who can look at the use the get (int index) and set (int index, Object obj)

Time:10-14

Topics are as follows:
There are two books on the desk, respectively is "journey to the west" "water margin"; There are three books on the shelf, respectively is "the romance of The Three Kingdoms", "selected poems of Shakespeare" "a dream of red mansions" use the interface of the get (int index) and set (int index, Object obj) method, will China's four great classics in accordance with the "water margin", "three kingdoms" "journey to the west" "a dream of red mansions" put together the order of the
Optimization of the time don't use a constructor thank bosses like
Package GenericProgramma;

The import com. Sun. Deploy. Config. Config.

Import the Java. Util. ArrayList;
Import the Java. Util. List;
The class ListTest
{
Public static void main (String [] args)
{
List List1=new ArrayList<> (a);
List1. Add (" journey to the west ");
List1. Add (" water margin ");
System. The out. Println (" there are two books on the desk are ");
For (int j=0; j{
System. The out. Print (list1. Get (j) + "\ t");
}
System.out.println();

List List2=new ArrayList<> (a);
List2. Add (" the romance of The Three Kingdoms ");
List2. Add (" Shakespeare's poems ");
List2. Add (" a dream of red mansions ");
System. Out. Println (" shelf there are three books are ");
For (int I=0; I & lt; List2. The size (); I++)
{
System. The out. Print (list2. Get (I) + "\ t");
}
System.out.println();
System. The out. Println (" reorder: "+ list1. Get (list1. The size () - 1) +", "+ list2. Get (list2. The size () - 2) +", "+ list1. Get (list1. The size () - 2) +", "+ list2. Get (list2. The size () - 1));
}
}

CodePudding user response:

 
List TableList=new ArrayList<> (a);
TableList. Add (" journey to the west ");
TableList. Add (" water margin ");
List BookList=new ArrayList<> (a);
BookList. Add (" the romance of The Three Kingdoms ");
BookList. Add (" Shakespeare ");
BookList. Add (" a dream of red mansions ");
BookList. Add (0, tableList. Get (1));
BookList. Set (2, tableList. Get (0));
System. The out. Println (String. Join (", ", bookList));

CodePudding user response:

Don't know what is the meaning of this, if is the actual development, have the type in the table to distinguish what kind of books and number of what,

CodePudding user response:

refer to the second floor liuyh1024 response:
don't know what is the meaning of this, if is the actual development, have the type in the table to distinguish what kind of books and number of what,

Bosses I haven't the step into the development of

CodePudding user response:

Now is the entrance

CodePudding user response:

reference 1st floor pws22 response:
 
List TableList=new ArrayList<> (a);
TableList. Add (" journey to the west ");
TableList. Add (" water margin ");
List BookList=new ArrayList<> (a);
BookList. Add (" the romance of The Three Kingdoms ");
BookList. Add (" Shakespeare ");
BookList. Add (" a dream of red mansions ");
BookList. Add (0, tableList. Get (1));
BookList. Set (2, tableList. Get (0));
System. The out. Println (String. Join (", ", bookList));

Bosses last few words can write a note? The temporary has not learned

CodePudding user response:

You this order without any rules, is put in the order that fixed, what number should have to order

CodePudding user response:

There is no based knowledge after the item is to strengthen the memory
  • Related