Java Basic Data Types | Practice | GeeksforGeeks

Read a value and store it in the appropriate Java Data Type. 

Example 1:
Input: 
18 
abc 
9.9876 
Output:
18 
abc 
9.9876 
Explanation:
The three inputs are stored in approriate 
data types and then printed in order.

 
Your Task:
Your task is to complete each of the given functions 
javaIntType() : read an integer input, store it in appropriate data type and return it. 
javaStringType() : read a string input, store it in appropriate data type and return it.  
javaFloatType() : read a float input, store it in appropriate data type and return it. 
Each of the function have an object of Scanner in the parameter to be used to read the input.

Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
0
indhu64771 month ago
class Solution {
   int javaIntType(Scanner sc) {      return sc.nextInt();   }      String javaStringType(Scanner sc) {    return sc.next();         }      float javaFloatType(Scanner sc) {       return sc.nextFloat();         }};
+2
imohdalam1 month ago
Java | O(1)
class Solution {

    int javaIntType(Scanner sc) {
        // code here
        int ans = sc.nextInt();
        
        return ans;
    }
    
    String javaStringType(Scanner sc) {
        // code here
        String ans = sc.next();
        
        return ans;
    }
    
    float javaFloatType(Scanner sc) {
        // code here
        float ans = sc.nextFloat();
        
        return ans;
    }
};
0
rohitpandey484Premium2 months ago
Java Solution 
class Solution {
   int javaIntType(Scanner sc) {       return sc.nextInt();   }      String javaStringType(Scanner sc) {       return sc.next();   }      float javaFloatType(Scanner sc) {       return sc.nextFloat();   }};
0
sachin1947s2 months ago
Class  Solution
 
0
vishwajeetofficial20222 months ago
//JAVA SOLUTION

class Solution {

    int javaIntType(Scanner sc) {
        // code here
           return sc.nextInt();
    }
    
    String javaStringType(Scanner sc) {
        // code here
          return sc.next();
    }
    
    float javaFloatType(Scanner sc) {
        // code here
          return sc.nextFloat();
    }
};
0
shaktig1011013 months ago
package abc;
import java.util.Scanner;
class Solution {

int nextIntType(Scanner sc ){
return sc.nextInt ();
}

String nextStringType(Scanner sc){
return sc.next();
}

Float nextFloatType(Scanner sc){
return sc.nextFloatType();
}

}
0
neetathakur88783 months ago
class Solution {
   int javaIntType(Scanner sc) {       return sc.nextInt();   }      String javaStringType(Scanner sc) {       return sc.next();   }      float javaFloatType(Scanner sc) {       return sc.nextFloat();   }};
0
rishitachail1253 months ago
// { Driver Code Startsimport java.io.*;import java.util.*;
class GFG {   public static void main(String args[]) throws IOException {       Scanner sc = new Scanner(System.in);       int t = sc.nextInt();              while (t-- > 0) {           Solution ob = new Solution();           System.out.println(ob.javaIntType(sc));           System.out.println(ob.javaStringType(sc));           System.out.println(ob.javaFloatType(sc));       }   }}// } Driver Code Ends
class Solution {
   int javaIntType(Scanner sc) {       // code here       return sc.nextInt();   }      String javaStringType(Scanner sc) {       // code here       return sc.next();   }      float javaFloatType(Scanner sc) {       // code here       return sc.nextFloat();   }};
0
gauravverma9918187053 months ago
#Code Here#
class Solution {

int nextIntType(Scanner sc ){
return sc.nextInt ();
}

String nextStringType(Scanner sc){
return sc.next();
}

Float nextFloatType(Scanner sc){
return sc.nextFloatType();
}

};

0
pinaksangamnerkar1234 months ago
ArrayList<Integer> list = new ArrayList<Integer>();
        
        int res = 0;
        
        for(Integer i1: A)
            res ^= i1;
            
        for(Integer i1: A)
            list.add(res ^ i1);
    
        
        return list;
    }
}
We strongly recommend solving this problem on your own before viewing its editorial. Do you still
                    want to view the editorial?
 Login to access your submissions. 

Problem


Contest

Reset the IDE using the second button on the top right corner.
Avoid using static/global variables in your code as your code is tested against multiple test cases and these tend to retain their previous values.
Passing the Sample/Custom Test cases does not guarantee the correctness of code. On submission, your code is tested against multiple test cases consisting of all possible corner cases and stress constraints.
You can access the hints to get an idea about what is expected of you as well as the final solution code.
You can view the solutions submitted by other users from the submission tab.