Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: problem of remove student from list

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default problem of remove student from list

    I have problem with removing student(supprimerEtudiant) and showing student on list (afficherEtudiant). Plz help me to review my code
    Here is my code
    public class Classe{
    String name;
    ArrayList<Student>studentList = new ArrayList<Student>();
    int size = studentList.size();
    int i;
    Student stu = new Student();
    public void ajouterEtudiant(){
    for (int i =1; i<3; i++){

    write("Student ID: ");
    stu.id = readString();
    write("Student Name: ");
    stu.name = readString();
    write("Student Age: ");
    stu.age = readInt();

    studentList.add(stu);
    }
    }
    public int supprimerEtudiant(int i){
    for (i=0; i<studentList.size();i++){
    if(studentList.get(i).id.equals(stu.id)){
    studentList.remove(i);
    break;
    }
    }
    return i;
    }
    public void afficherEtudiant(){
    for (i=0; i<studentList.size();i++){
    System.out.print(studentList);
    }
    }
    }


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: problem of remove student from list

    When posting code, please use the highlight tags to preserve formatting.

    What exactly is the problem with this code? What does it do? What do you expect it to do? How do they differ?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Please Help: Simple Double Linked List (remove, addBefore, )
    By yeohv in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 30th, 2012, 12:58 PM
  2. trouble with add and remove method on doubly linked list
    By BetterCallSaul in forum What's Wrong With My Code?
    Replies: 9
    Last Post: July 22nd, 2012, 07:12 PM
  3. trouble with add and remove method on doubly linked list
    By BetterCallSaul in forum What's Wrong With My Code?
    Replies: 1
    Last Post: July 20th, 2012, 02:51 PM
  4. Help with using iterator remove on double linked list
    By papated21 in forum Collections and Generics
    Replies: 3
    Last Post: October 18th, 2011, 09:22 PM
  5. Replies: 1
    Last Post: March 15th, 2010, 10:03 PM

Tags for this Thread