Home > Back-end >  Code analytical resolution two sentences for bosses told!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Code analytical resolution two sentences for bosses told!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Time:10-14

Package GenericProgramma;

The import java.net.StandardSocketOptions;
Import the Java. Util. ArrayList;
Import the Java. Util. Collections;
import java.util.*;
The class IteratorTest
{
Public static void main (String args [])
{
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));
}
}

BookList. Add (0, tableList. Get (1));
BookList. Set (2, tableList. Get (0));
System. The out. Println (String. Join (", ", bookList)); Is the meaning of these lines

CodePudding user response:

The
refer to the original poster Lin_bai_ response:
package GenericProgramma;

The import java.net.StandardSocketOptions;
Import the Java. Util. ArrayList;
Import the Java. Util. Collections;
import java.util.*;
The class IteratorTest
{
Public static void main (String args [])
{
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));
}
}

BookList. Add (0, tableList. Get (1));
BookList. Set (2, tableList. Get (0));
System. The out. Println (String. Join (", ", bookList)); Is this a few words of the meaning of


Learn to yourself to check the Java API

The join
Public static String join (CharSequence delimiter,
Iterable<? Extends CharSequence> Elements)
Returns a new String composed of copies of the CharSequence elements joined together with a copy of the specified delimiter.
For example,

List Strings=new LinkedList<> (a);
Java strings. The add (" "); Strings. The add (" is ");
Strings. The add (" cool ");
String message=String. Join (" ", strings);
//message returned is:
"Java is cool"
Set Strings=new LinkedHashSet<> (a);
Java strings. The add (" "); Strings. The add (" is ");
Strings. The add (" very "); Strings. The add (" cool ");
String message=String. Join (" - ", strings).
//message returned is: "Java - is - very cool"

CodePudding user response:

The first sentence, tableList will be the second element is inserted into the bookList first
The second sentence, will be the third element of bookList for tableList the first element of the
The elements of the third sentence is printed bookList

CodePudding user response:

Ok thank you
  • Related