Home > Back-end >  What can replace system. Out println, input a bit less
What can replace system. Out println, input a bit less

Time:10-12

The code in this picture I don't know what should add in where?

CodePudding user response:

The answer is not to tell you is in the figure
PrintStream ps=new PrintStream System. (out);
Ps. Println (" 123 ");//don't have to play System. Out, use ps directly

CodePudding user response:

Write a utility class, compiled. Clas file, then save U disk with a can be used at any time,
Code like this
The public class U
{
Public static void pl (byte a) {
System.out.println(a);
}
Public static void pl (short a) {
System.out.println(a);
}
Public static void pl (int a) {
System.out.println(a);
}
Public static void pl (a) {
System.out.println(a);
}
Public static void pl (float a) {
System.out.println(a);
}
Public static void pl (double a) {
System.out.println(a);
}
Public static void pl (Boolean a) {
System.out.println(a);
}
Public static void pl {char (a)
System.out.println(a);
}
Public static void pl (String a) {
System.out.println(a);
}
Public static void byte (a) p {
System. The out. Print (a);
}
Public static void (short a) {p
System. The out. Print (a);
}
Public static void (int a) {p
System. The out. Print (a);
}
Public static void p (a) {
System. The out. Print (a);
}
Public static void (float a) {p
System. The out. Print (a);
}
Public static void (double a) {p
System. The out. Print (a);
}
Public static void (Boolean a) {p
System. The out. Print (a);
}
Public static void p {char (a)
System. The out. Print (a);
}
Public static void p (String a) {
System. The out. Print (a);
}
}

CodePudding user response:

Then, you put the u.c. lass, copy, take, you need to use when the u.c. lass in the source directory, directly in U.p l (); Can replace System. Out. The println ();
like that,Public class ThreadTest02
{
Public static void main (String [] which) {
Thread t2=new Thread (new Processor ());
T2. Start ();
}
}

The class Processor implements Runnable
{
Public void the run () {
for(int i=0; i <10; I++) {
//System. Out.println (" run - & gt; "+ I);
U.p l (" run - & gt; "+ I);
}
New Thread (new Processor ()). The run ();
}

}

CodePudding user response:

Actually do so also no necessary, eclipse, and directly syso then press Alt +/came out, also pretty fast

CodePudding user response:

reference 1st floor qybao response:
figure the answer is not to tell you is in the
PrintStream ps=new PrintStream System. (out);
Ps. Println (" 123 ");//don't have to play System. The out, it is ok to directly use ps

Thank you, I know

CodePudding user response:

King * reference 4 floor response:
actually do so also no necessary, eclipse, and directly syso then press Alt +/came out, also pretty fast

Thank you, I know
  • Related