From 686f98f2963422f39d10c8180eff30c45bdc3f9a Mon Sep 17 00:00:00 2001 From: Matthew Ellison Date: Tue, 12 Feb 2019 12:12:48 -0500 Subject: [PATCH] Added a Helo World program --- helloWorld.java | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 helloWorld.java diff --git a/helloWorld.java b/helloWorld.java new file mode 100644 index 0000000..34b7f11 --- /dev/null +++ b/helloWorld.java @@ -0,0 +1,38 @@ +//Java/JavaTutorials/helloWorld.java +//Matthew Ellison +// Created: 02-11-19 +//Modified: 02-11-19 +//This is a simple hello world program written in java + +import java.util.Scanner; + +public class helloWorld{ + public static void main(String[] argv){ + String hello = "Hello" + ' ' + "World"; + //Print a static string + System.out.println("Hello World"); + //Print a variable string + System.out.printf("%s again\n", hello); + //Add a number to a string + int num = 2; + String hello2 = hello; + hello2 += ' '; + hello2 += num; //Apparently an automatic conversion is done + System.out.println(hello2); + //Get input and use it to print a message + java.util.Scanner input = new Scanner(System.in); + System.out.print("What number do you want to print? "); + num = input.nextInt(); + input.close(); + hello2 = hello + ' ' + num; + System.out.println(hello2); + } +} + +/* Results: +Hello World +Hello World again +Hello World 2 +What number do you want to print? 15 +Hello World 15 +*/ \ No newline at end of file