Code example for Scanner

Methods: nextDoublenextLine

0
        
        try { 
            // TODO code application logic here 
             
            File file = new File("student.txt");
            Scanner input = new Scanner(System.in);
            Student s1 = new Student();
            Student s2 = new Student();
            System.out.print("Enter Student Name ==> ");
            s1.setName(input.nextLine());
            System.out.print("Enter Student GPA  ==> ");
            s1.setGPA(input.nextDouble());
            System.out.printf("Writing to %s...\n",file.getName());
            s1.Save(file);
            System.out.printf("Reading from %s...\n",file.getName());
             
            s2.Load(file);
            System.out.printf("Student: %s\n", s2);
             
        } catch (Exception ex) {
Connect your IDE to all the code out there  Get Codota for Java