+ 1
Java
Java is my life
2 Answers
+ 4
I enjoy Java as well. :)
Since you like it, I'll give you a little trick you can use that saves me a lot of annoyance and time with Java. As I'm sure you've figured out by now, having to type out System.out.println() eventually becomes annoying to do all the time.
I've posted some code for you and given you 3 examples of how you can simplify that process greatly. You can do a import static on System.out, which allows you to use out.println() without having to type System. each time also. As well, I created two methods for it, and it'll allow you to just type print() and println(). If you use the methods, I would just create a file that you keep your own custom functions in, and then just import it into your projects so you can use it for all of them without having to recreate them each time.
https://code.sololearn.com/cIJxDslJviZg/#java
// This import allows us to use out.println()
// instead of having to use System.out.println()
import static java.lang.System.out;
public class Program
{
// custom function to simplify System.out.print
public static void print(String str) {
System.out.print(str);
}
// customer function to simplify System.out.println
public static void println(String str) {
System.out.println(str);
}
public static void main(String[] args) {
// EXAMPLE OF PRINT FUNCTION
print(":::PRINT FUNCTION EXAMPLE:::");
print("This ");
print("Doesnt ");
print("Print NewLine\n");
// EXAMPLE OF PRINTLN FUNCTION
println("");
println(":::PRINTLN FUNCTION EXAMPLE:::");
println("This");
println("Prints");
println("With New Line");
// EXAMPLE OF SYSTEM.OUT IMPORT
out.println("");
out.println(":::SYSTEM.OUT IMPORT EXAMPLE:::");
out.print("No New Line");
out.println("");
out.println("This");
out.println("Has");
out.println("NewLine");
}
}
0
what?