Lecture 6: Primitive Data Types Solution
PRIMITIVES PROBLEM STATEMENT:
// Implement an ‘int’ data type, intValue, initialized as 4326
PRIMITIVES SOLUTION:
// int intValue = 4326;
// 4326
Hi there, This is Marius from AlefTav Coding. In today's lecture I will look at another of Java's 'primitive' data types. Your homework was the coding exercise, 'Implement an ‘int’ data type, intValue, initialized as 4326'
My solution is, data type, 'int', storage name, 'intValue' initialized as the number, 4326. I am using the Java data type, 'int' because I work here with a discrete, whole number, and not a decimal number, as in the previous lecture. Besides, 'double' and 'int', Java's other 'primitive' data types are 'byte', 'short', 'long', 'float', 'char' and 'boolean'.
public class Lecture6 {
public static void main(String[] args) {
// TODO: Implement 'intValue' as 4326
System.out.print(intValue);
}
}
In my class, 'Lecture6' is the usual main() method. Then, the 'TODO' comment line where the solution code will appear. And a print statement to display the data stored at the location, 'intValue'.
Removing the 'TODO' comment, I add in my solution, int intValue = 4326.
When the code is in order I can run the program. The output of the code will be the number, 4326, displayed in a separate line.
In this lecture you learnt how to implement Java's primitive data type, 'int'. Next time you will learn how to implement a reference data type.
This is Marius from AlefTav Coding. Until next time, KEEP CODING.
If you found this tutorial helpful, please upvote, subscribe, like and share. You can find me at the following links.
https://www.youtube.com/channel/UCUr-H9hVVa0ulnQcqQKYmIw?disable_polymer=true
https://plus.google.com/101690479974829208565
https://www.slideshare.net/MariusClaassen1/java-the-basics?qid=4ff400a3-6e42-4e61-9d23-e48029081df6&v=&b=&from_search=5
https://www.udemy.com/course/1435298/manage/basics/
https://d.tube/#!/c/mariusclaassen
https://steemit.com/@mariusclaassen
▶️ DTube
▶️ IPFS