Please advice on where can I find the lib in order to use the shorter expression of System.out.println() and where should I place that lib.
package some.useful.methods;
public class B {
public static void p(Object s){
System.out.println(s);
}
}
package first.java.lesson;
import static some.useful.methods.B.*;
public class A {
public static void main(String[] args) {
p("Hello!");
}
}
Using System.out.println() is bad practice (better use logging framework) -> you should not have many occurences in your code base. Using another method to simply shorten it does not seem a good option.
void p(String l){
System.out.println(l);
}
Shortest. Go for it.
A minor point perhaps, but:
import static System.out;
public class Tester
{
public static void main(String[] args)
{
out.println("Hello!");
}
}
...generated a compile time error. I corrected the error by editing the first line to read:
import static java.lang.System.out;
For Intellij IDEA type sout and press Tab.
For Eclipse type syso and press Ctrl+Space.
In Java 8 :
List<String> players = new ArrayList<>();
players.forEach(System.out::println);