Data types in JAVA Data types specify the different sizes and values that can be stored in the variable. There are two types of data types in Java: Primitive data types: The primitive data types include boolean, char, byte, short, int, long, float and double. Non-primitive data types: The non-primitive data types include Classes, Interfaces, and Arrays. Java Primitive Data Types: In Java language, primitive data types are the building blocks of data manipulation. These are the most basic data types available in Java language. Java is a statically-typed programming language. It means, all variables must be declared before its use. That is why we need to declare variable's type and name. There are 8 types of primitive data types: boolean data type byte data type char data type short data type int data type long data type float data type double data type Boolean Data Type The Boolean data type is used to store only ...
Java Break Statement When a break statement is encountered inside a loop, the loop is immediately terminated and the program control resumes at the next statement following the loop. The Java break statement is used to break loop or switch statement. It breaks the current flow of the program at specified condition. In case of inner loop, it breaks only inner loop. We can use Java break statement in all types of loops such as for loop , while loop and do-while loop . Syntax: jump-statement ; break; Java Break Statement with Loop Example: //Java Program to demonstrate the use of break statement //inside the for loop. public class BreakExample { public static void main (String[] args) { //using for loop for ( int i= 1 ; i<= 10 ; i++)...
Comments
Post a Comment