import java.util.ArrayList;
import java.util.List;
public class Test {
public static void main(String[] args) {
List<String> list = new ArrayList<>();
list.add("张三");
list.add("李四");
list.add("王五");
String result = getResult(list);
System.out.println(result);
}
public static String getResult (List<String> list){
if (list == null|| list.size() == 0){
return null;
}
StringBuilder sb = new StringBuilder();
for(String s : list){
sb.append(s).append(" ");
}
Result = sb.toString String ();
return result.substring (0, result.length () -. 1);
}
}
to write such a program.
Shortcut
Alt + F8 to add a breakpoint Ctrl + D is quickly copy a row
of small insects Debug --- that is
under little insects can single-step operation.
Each time you press F8, the program execution from the breakpoint, line by line, until the end of the run.
resume
skip to the next breakpoint directly from the current breakpoint.
View all breakpoints
Ban all breakpoints:
In the process of debugging, breakpoints do not know which problem. A line of code bug, want to skip all breakpoints,
After clicking the breakpoint changes from red to gray, then press F9 to jump over all the breaks you, will not stop
conditional breakpoints
Assuming this break point, string s need only meet the content breakpoint Zhang
Ctrl + Shift + F8
Conditions will come out a window
Enter java expression
Zhang string s content only meet breakpoint
After setting, to meet the conditions will stay,
list.add ( "Joe Smith"); stopover, the other did not stay. If the conditional breakpoint removed, it will stay.
Expression evaluation:
In the process of debugging breakpoints, after a certain breakpoint To see what the result is a calculated value
After starting debug, select the list. Then Alt + F8
Press Enter
We can see the value in the current list
Run to the specified line:
Alt + F9 to run the specified breakpoint from the line.
setValue: set value
String result = getResult (list);
Press F2 null fill in the list
To test
if (list == null|| list.size() == 0){
return null;
}
这段函数的输出是否一致