// HelloDate.java
import java.util.Date;
public class HelloDate
{
public static void main(String[] args)
{
System.out.print("Hello, it’s: "); // no newline
System.out.println(new Date()); // newline
// System.out.println(new Date().toString());
}
}
/*
javac HelloDate.java
java HelloDate
Hello, it’s: Thu Jul 13 14:24:22 EEST 2023
*/
*****************************************************************************************
*****************************************************************************************
*****************************************************************************************
*****************************************************************************************
*****************************************************************************************
Exercise 3-2: (1) Following the HelloDate.java example in this chapter, create a “hello, world” program that simply displays that statement. You need only a single method in your class (the “main” one that gets executed when the program starts). Remember to make it static and to include the argument list, even though you don’t use the argument list. Compile the program with javac and run it using java. If you are using a different development environment than the JDK, learn how to compile and run programs in that environment.
public class Hello
{
public static void main(String[] args)
{
System.out.println("Hello, world!");
}
}
/*
javac Hello.java
java Hello
Hello, world!
*/