how to display text values
this tutorial shows how to display text values like words and presents a simple programming task to complete
when you have finished this page, return to the slides on
program requirements
code a simple program to output text values like Hello and Goodbye
learning-point
code
use System.out.println( ) to display a text value you want to output use "speech marks" to create a text value development work
read a program requirement to understand what the the program should output or display read a user interface design to see what the output should look like
introducing the code
here is the new code that will be featured
1 System.out.println();
2 System.out.println( "Hi" );
understanding the code
on line 1 the println command is shown, it is used to display output in the console notice the capital S for System, notice the dots between the words, notice println is read as print line, notice the semi-colon; at the end of the line this example on line 1 above will display a blank line because there is nothing inside the brackets, a blank line can be very useful! on line 2 the println command will display the word "Hi", (the speech marks will not display) The code above will produce this output in the console
Hi
println (print line) outputs whatever is within the brackets and then (invisibly) takes a newline Taking a newline after output means that any follow-on output will begin on the line below the previous line. In the example the first line is blank because the brackets were empty and then second line appears below the blank line. develop the code
Now that we have been introduced to println, let’s go on to prepare and run some code! There are some notes to read below before you open the project in read the user interface design below to get an idea of what the program will produce. user interface design
a user interface design helps to
plan what the code should output, check the code has produced the correct result
the final display for this project should look like this :
Hello, my name is Duke!
Hi Duke, great to meet you!
Goodbye Duke!
See you next time!
you can compare the finished program with this sample
Using the project frame
The are 3 files in the project click the document icon📄 in repl (frame) to toggle the file list. Click a file to view the contents.
is the program file you will edit and run README contains a guide to completing the work CODECLIP has some sample code that you can copy and paste
It is best to open the code frame in repl, preferably in a new browser window and arrange this window alongside the repl window
right click the “open in repl” link at the top right of the project frame below if you have a repl account you can fork the project to store your own copy project frame