how to have a only number type in java
class scratch{
public static Number haha(Number yo){
return yo;
}
public static void main(String[] args) {
System.out.println(haha( (int) 5 ));
System.out.println(haha( (double) 5.0 ));
System.out.println(haha( (long) 5 ));
System.out.println(haha( (float) 5.0 ));
//all of these classes extend the java.lang.Number class
System.out.println(haha("Hey"));
//error because the java.lang.String class does not extend the java.lang.Number class
}
}
Also in Java:
- how to check if a string contains only alphabets and space in java
- java 8 list stream delete by name
- create java windows application
- length of string java
- processing library cassette
- java convert String to int
- java loop hashmap
- bukkit java get max players
- char array to arraylist java
- print map java
- how to create a draw Rectangle in java
- java code to save excel data to mysql
- java type casting
- eliminar el primer caracter de un string java
- java nextpermutation
- writing to a text file java
- java int array
- sort elements with sortedset
- java previous permutation
- adding an element to the end of a linked list java
- java create window
- how to install java 8 on terminal os
- how to create gravity in java
- how to set a windows background image tkinter