when you start learning java and they show how to create your first program, the obligatory/traditional “hello world”. btw if you dont have java installed and havent run the hello world do it before you read this.
the hello world looks somthing like this:
public class Main { public static void main(String[] args) { System.out.println("Hello World"); } }
the line that outputs the “hello world” to the console is:
System.out.println("Hello World");
dont you think its a little to long to write? in php its just echo “hello world”; , in alot of other programming languages its print “hello world”;
no matter if your beginner or advanced student you will output stuff to the console for debugging etc.
for that purpose i created this class:
package your_package _name; public class S { public static void o(Object s) { System.out.println(s); } }
create an S class in your project and put that code there, dont forget to change the package name to your projects package .
using this class you can output to console like this:
S.o("hello world");
its much shorter then writing : System.out.print(“whatever”);
6 thoughts on “a better way to output to the java console”