Click here to Skip to main content
15,920,438 members
Home / Discussions / Java
   

Java

 
QuestionSorted Linked List [modified] Pin
Babylon Lion25-Nov-10 8:10
Babylon Lion25-Nov-10 8:10 
AnswerRe: Sorted Linked List Pin
TorstenH.25-Nov-10 19:54
TorstenH.25-Nov-10 19:54 
AnswerRe: Sorted Linked List Pin
Richard MacCutchan25-Nov-10 22:06
mveRichard MacCutchan25-Nov-10 22:06 
GeneralRe: Sorted Linked List Pin
TorstenH.25-Nov-10 23:25
TorstenH.25-Nov-10 23:25 
GeneralRe: Sorted Linked List Pin
Richard MacCutchan26-Nov-10 0:50
mveRichard MacCutchan26-Nov-10 0:50 
GeneralRe: Sorted Linked List Pin
Babylon Lion26-Nov-10 16:59
Babylon Lion26-Nov-10 16:59 
AnswerRe: Sorted Linked List Pin
Luc Pattyn26-Nov-10 4:50
sitebuilderLuc Pattyn26-Nov-10 4:50 
GeneralRe: Sorted Linked List Pin
Babylon Lion26-Nov-10 16:54
Babylon Lion26-Nov-10 16:54 
Thank you all for the replies. I modified the code, and now it compiles ans run with no errors. But it doesn't output anything?!
Any clue?
import java.io.*;
import java.util.*;

public class mainStudnetProg
{
    public static void main(String[] args)
    {
        StudentList studentList = new StudentList();

        try
        {
            Scanner infile = new Scanner(new FileReader("C:\\studentInfo.txt"));

            createStudentList(infile, studentList);
        }
        catch (FileNotFoundException fnfe)
        {
            System.out.println(fnfe.toString());
        }
    } // end main

    public static void createStudentList(Scanner infile, StudentList studentList)
    {
        String  fName;
        String  lName;
        int id;

        Student newStudent;
        while (infile.hasNextLine())
        {
        	if (!infile.hasNextLine()){
        		break;
        	}
    		infile.hasNextLine();
    		fName = infile.nextLine();	
 
        	
            // If there's no line, then break out of the loop.
            if (!infile.hasNextLine()){
            	break;
            }
            infile.hasNextLine();
            lName = infile.nextLine();

            if (!infile.hasNextInt()){
            	break;
            }
            infile.hasNextInt();
            id = infile.nextInt();
            
            if (!infile.hasNextLine()){
            	break;
            }
            infile.hasNextLine();
            infile.nextLine();
            
            newStudent = new Student();
            newStudent.setStudentInfo(fName, lName, id);

            studentList.insertFirst(newStudent);
        }
    }
}

GeneralRe: Sorted Linked List Pin
Luc Pattyn26-Nov-10 17:18
sitebuilderLuc Pattyn26-Nov-10 17:18 
QuestionCould not create system bitmap Pin
evan earnest25-Nov-10 2:09
evan earnest25-Nov-10 2:09 
AnswerRe: Could not create system bitmap Pin
TorstenH.25-Nov-10 2:58
TorstenH.25-Nov-10 2:58 
GeneralRe: Could not create system bitmap Pin
evan earnest25-Nov-10 18:53
evan earnest25-Nov-10 18:53 
QuestionHow do you build your GUIs? Pin
TorstenH.23-Nov-10 21:36
TorstenH.23-Nov-10 21:36 
AnswerRe: How do you build your GUIs? Pin
David Skelly23-Nov-10 22:13
David Skelly23-Nov-10 22:13 
AnswerRe: How do you build your GUIs? Pin
Cedric Moonen23-Nov-10 23:00
Cedric Moonen23-Nov-10 23:00 
GeneralRe: How do you build your GUIs? Pin
TorstenH.23-Nov-10 23:12
TorstenH.23-Nov-10 23:12 
GeneralRe: How do you build your GUIs? Pin
Cedric Moonen23-Nov-10 23:22
Cedric Moonen23-Nov-10 23:22 
GeneralRe: How do you build your GUIs? Pin
TorstenH.23-Nov-10 23:27
TorstenH.23-Nov-10 23:27 
AnswerRe: How do you build your GUIs? Pin
Nagy Vilmos24-Nov-10 3:18
professionalNagy Vilmos24-Nov-10 3:18 
AnswerRe: How do you build your GUIs? Pin
LloydA11125-Nov-10 7:50
LloydA11125-Nov-10 7:50 
AnswerRe: How do you build your GUIs? Pin
Alok Sharma ji30-Nov-10 19:47
Alok Sharma ji30-Nov-10 19:47 
GeneralRe: How do you build your GUIs? Pin
TorstenH.1-Dec-10 23:24
TorstenH.1-Dec-10 23:24 
QuestionSocket programming Pin
vidhyaej23-Nov-10 19:52
vidhyaej23-Nov-10 19:52 
AnswerRe: Socket programming Pin
TorstenH.23-Nov-10 21:41
TorstenH.23-Nov-10 21:41 
GeneralRe: Socket programming Pin
vidhyaej23-Nov-10 22:01
vidhyaej23-Nov-10 22:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.