In this episode of Java programming language, we are taking a sneak peek into the variables & data types available in java.
We will be covering 5 commonly used data types
1. String
2. char
3. float
4. int
5. boolean
The program explained in this episode
File Name: Variables.java
Code :
import java.util.Scanner;
public class Variables {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String item;
char batch;
float price;
int qty;
boolean isExpired;
System.out.println("Enter the item : ");
item = sc.nextLine();
System.out.println("Enter the batch : ");
batch = sc.next().charAt(0);
System.out.println("Enter the price : ");
price = sc.nextFloat();
System.out.println("Enter number of items : ");
qty = sc.nextInt();
System.out.println("Is the item expired : ");
isExpired = sc.nextBoolean();
System.out.println("\n\n");
System.out.println("Item : " + item);
System.out.println("Batch : " + batch);
System.out.println("Price : " + price);
System.out.println("Quantity : " + qty);
System.out.println("Expired ? : " + isExpired);
}
}
Java Programming Previous Episodes
1. Basics - • Basics - Java Programming Episode 1
2. OOPS - • OOPs - Java Programming Episode 2
3. IDE Setup - • IDE Setup - Java Programming Episode 3
4. Main Method - • Postmortem of the main method - Java Progr...
Please share valuable feedback, share it with your friends, and let me know if you have any queries/concerns.
Acknowledgments
Music: Moose from Bensound.com
Images: Designed by Freepik
Thumbnail image: www.contracttesting.com
Thanks,
Mallu Buddy
On this page of the site you can watch the video online Variables & Data Types - Java Programming Episode 5 with a duration of hours minute second in good quality, which was uploaded by the user MalluBuddy 07 September 2020, share the link with friends and acquaintances, this video has already been watched 807 times on youtube and it was liked by 56 viewers. Enjoy your viewing!