check type of variable java
public class MyClass {
public static void main(String args[]) {
int x = 5;
System.out.println(((Object)x).getClass().getSimpleName());
}
}
check type of variable java
public class MyClass {
public static void main(String args[]) {
int x = 5;
System.out.println(((Object)x).getClass().getSimpleName());
}
}
different types of variables in java
// String - stores text, such as "Hello". String values are surrounded by double quotes
String str = "Hello";
// int - stores integers (whole numbers), without decimals, such as 123 or -123
int nbr = 0;
// float - stores floating point numbers, with decimals, such as 19.99 or -19.99
float pie = 3.141592;
// char - stores single characters, such as 'a' or 'B'. Char values are surrounded by single quotes
char letter = "A";
// boolean - stores values with two states: true or false
boolean checker = true;
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us