Primitive types problem statement
Implement an ‘int’ data type, intValue, initialized as 4326
Primitive types solution code
int intValue = 4326;
Primitive types solution output
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'
public class Lecture6 {
public static void main(String[] args) {
// TODO: Implement an ‘int’ data type, intValue, initialized as 4326
System.out.println(intValue);
}
}
My solution is, data type, 'int', followed by 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.
In my class, Lecture6 is the usual main() method. Then, the TODO comment line where the solution code will appear. Next, a print statement to display the data stored at the location, intValue.
int intValue = 4326;
Removing the TODO comment, I add in my solution, int intValue = 4326.
When the code is correct I can then 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. Thank you for reading and KEEP CODING.
You can earn extra steem and basic income at the referral URLs below:
https://steemengine.net/join?r=4539
https://old.steemfollower.com/?r=18345
https://minnowsmith.party/
https://www.mannabase.com/?ref=2a6bce2ce9
https://www.swiftdemand.com/?referred_by=mariusclaassen
https://litecoin-faucet.com/page/faucet
http://sociali.io/ref/Fd15253240
This post was made from https://ulogs.org