We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
what is getting wrong here?
int array is not taking input as 213333333333333333333333333333333 ,-1000000000000000 .?so what to do to run ?
how to handel the third exception .?
public static void main(String[] arg)throws NoSuchElementException{
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
int x=1,n=5;
try{
Scanner sc = new Scanner(System.in);
int s= sc.nextInt();
long[] arr= {-150,150000,1500000000};
for (int i=0;i<=2;i++){
System.out.println(arr[i]+" can be fitted in ");
if ((arr[i] < 127) && (arr[i] > -127)){
System.out.println("* byte");
}
if (( -32767 < arr[i]) && (arr[i] < 32768)){
System.out.println("* short");
}
if ((-2e31< arr[i]) && (arr[i] < (2e31)-1)){
System.out.println("* int ");
}
if ((-2e63< arr[i] ) && (arr[i] <=(2e63)-1)){
System.out.println("* long ");
}else
if (arr[i] > (2^63)-1){
System.out.println(arr[i]+" can't be fitted anywhere");
}
}
}
catch(Exception e){
System.out.println("The exception :"+ e);
}
}
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Datatypes
You are viewing a single comment's thread. Return to all comments →
what is getting wrong here? int array is not taking input as 213333333333333333333333333333333 ,-1000000000000000 .?so what to do to run ? how to handel the third exception .?
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*; import java.util.Scanner;
public class Solution {
}