Lecture 13: Reference Types Solution
Reference Types coding exercise
Declare a String named ‘words’ initialized as ‘In the beginning’
public class Lecture13 {
public static void main(String[] args) {
// TODO: Declare a String named ‘words’ initialized as ‘In the beginning’
}
}
Java Reference coding solution
String words = "In the beginning";
Hi there, This is Marius from AlefTav Coding. In this lecture you will learn the solution to the reference data type coding exercise.
You were required to declare a String named words initialized as In the beginning.
public class Lecture13 {
public static void main(String[] args) {
String words = "In the beginning";
}
}
Here, above, in the solution, you see the Java pattern, declaration (String words), initialization (words = "In the beginning;"). The problem statement asks that the dataType must be a String. Next, it asks that the storage name must be, words. Finally, the value you need to store is the text, In the beginning. These words appear in quotation marks bacause it is text, rather than numbers. Then, to complete the statement, add a semi-colon (;).
So, this program has a class, Lecture13 with one method, main(). Then, remove the TODO comment and replacing it with the solution, String words = "In the beginning";.
That is it for this lecture where you learned the solution to the Java reference coding exercise.
Next time, I will look at the situation where your java program asks you for information.
I am Marius from AlefTav Coding. Till our next lesson, KEEP CODING.
Please upvote, re-steem and share. For more of this you can find me at the following links.
https://busy.org/@mariusclaassen
https://steemit.com/@mariusclaassen
https://d.tube/#!/c/mariusclaassen
https://www.udemy.com/java-8-for-complete-beginners/learn/v4/overview