Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JavaMail using list iterator create student details
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


madhu
using list iterator create student details
1 Answer(s)      5 years and 8 months ago
Posted in : JavaMail



Advertisement
View Answers

May 4, 2009 at 11:40 AM


Hi Friend,

First of all we would like to tell you that you can not perform comparison on the Class objects therefore for sorting the class Objects we have to first fetch them and then after sorting them according to some specific values we would have to add them into another list to print them.

Here we are sending you a sample code which will describe you how to create Student class and add its properties to the List .

import java.util.*;

class Student{
private int roll;
private String name;
private int marks;

public void setRoll(int roll){
this.roll = roll;
}
public int getRoll(){
return roll;
}

public void setName(String name){
this.name = name;
}
public String getName(){
return name;
}

public void setMarks(int marks){
this.marks = marks;
}
public int getMarks(){
return marks;
}
}

public class SortStudents
{
public static void main(String args[]){
List stu= new ArrayList();
Student st1= new Student();
st1.setRoll(101);
st1.setName("Amit");
st1.setMarks(56);
Student st2= new Student();
st2.setRoll(103);
st2.setName("Anil");
st2.setMarks(66);
Student st3= new Student();
st3.setRoll(103);
st3.setName("Ankit");
st3.setMarks(76);
stu.add(st1);
stu.add(st2);
stu.add(st3);
ListIterator listItr =(ListIterator)stu.listIterator();
while(listItr.hasNext()){
Student stud =(Student)listItr.next();
System.out.print(" "+stud.getRoll());
System.out.print(" "+stud.getName());
System.out.println(" "+stud.getMarks());
}
}
}

Hope that this will help you in solving your problem.

Thanks
RoseIndia Team


Related Tutorials/Questions & Answers:
using list iterator create student details - JavaMail
using list iterator create student details  write a java program to create student class with particulars like name, rno, marks,etc. and print them in ascending order using iterator(list iterator)  Hi Friend, First
How to create a Student data base using Linked List in java
How to create a Student data base using Linked List in java  I want a program by using linked list in java. The data stored must... Record2 sandhya 22 5apr By using linked list I hve
Advertisements
how to develop student details using springs
how to develop student details using springs  how to develop student details using springs
student details
student details  create an application for details of 1st to 5th standard students by using loops and scanner
student details
student details  hi sir/madam i have a doubt in PHP how to insert student details using mysql with php..   Have a look at the following link: PHP Mysql insert
List iterator java example
Java List Iterator is an interface in the collection framework. List is an interface. Its all elements can be traversed by the Iterator. Java List Iterator has methods hasNext() and next() for traversing . Java List Iterator
Write a program to get student details and store in a database
Write a program to get student details and store in a database  Write a program to get student details and store in a database
program to create student report using java applet,read the input using text boxesand generate the grades..?
program to create student report using java applet,read the input using text boxesand generate the grades..?   sir plz give me java applet codes for above question
Java List Iterator
Java List Iterator is an interface in the collection framework.... It has methods hasNext() and next(). Example of Java List Iterator import java.util.*; public class iterator { public static void main(String
Java List Iterator Example
Java List Iterator Example In Java Collection framework every classes provides... to start the collection. By using this iterator objects you can access each element..."); Now call the iterator() method of list and store the result into the Iterator
Java Generic Iterator
Java Generic Iterator is the new feature added to the jdk1.5. It is used.... It is used with classes, methods and interfaces. Java Generics Iterator... class generic { public static void main(String[] args) { ArrayList list
Java For loop Iterator
Iterator can be used with the for loop also. Initialization of the Iterator is done before the for loop. Iterator has boolean value with the hasNext method. So no increment/decrement is required. Java for Loop Iterator
Java Array Iterator with Example
++) { list[i].add(ar[i][j]); } } Iterator it[] = { list[0].iterator(), list[1].iterator(), list[2].iterator(), list[3].iterator() }; for (int k = 0; k... Java Array Iterator is an interface in the collection framework. Java
Iterator Java Sample
Java Sample Iterator interface makes the traversing of the elements easy...() Java Sample Iterator Example import java.util.ArrayList; import... sample { public static void main(String[] args) { List list = new ArrayList
I tried to create a dropdown list using struts2.it is not working.can you find the errors in this code?
I tried to create a dropdown list using struts2.it is not working.can you find the errors in this code?  /jsp code for creating dropdownlist using...;/*form created*/ <p:select name="designation" label="Enter Designation " list
Iterator Java Order
List collection elements are ordered while set elements are unordered. The iterator() method of the List Interface gives elements in propersequence...(); Iterator setit = set.iterator(); System.out.println("List elemenys
student
student  how do i create a program that writes out the message :Welcome to Kaplan University!"   Hi Friend, Try the following code: class Message { public static void main(String[] args
Java Hashmap Iterator
Java HashMap Iterator is a collection class. It implements the Map interface. It keeps the data in the key and value form. Java HashMap has no iterator.... Set's all elements can be traversed by the Iterator. Java Hashmap Iterator
Java Hashtable Iterator
in the key and value form. Like hasmap, it has no iterator() method. Use the entrySet... be traversed by the Iterator. Java Hashtable Iterator Example import..."); hastab.put("e", "era"); Set s = hastab.entrySet(); Iterator
How to Create Student Registration Form with HTML Code?
will learn to create a student registration form using html code in easy steps...How to Create Student Registration Form with HTML Code? At present, the concept of online student registration form has emerged as a great relief
Iterator Java Size
The Java Iterator size() is the method of the collection Interface... in the collection. Java Size Iterator Example import java.util.*; public class size { public static void main(String[] args) { List list = new
Iterator Java While
The Java While loop Iterator is the top tested loop. It is in two forms while(), do while() While loop is mostly used with Iterator compared to for loop Java While Loop Iterator Example import java.util.ArrayList; import
Java Hasnext Iterator
Java HasNext Iterator is the method of the Iterator Interface. It returns... of false vale loop terminates. Java HasNext Iterator Example import...", "april", "may", "june" }; ArrayList list = new ArrayList(); for (String m
Hi, I'm new to JSP I want to create 3 dropdown list each depend on the other and get the options from the database using JSP
Hi, I'm new to JSP I want to create 3 dropdown list each depend on the other and get the options from the database using JSP  as i said i want to create 3 drop dropdown list each depend on the other and get the options from
stack using linked list
stack using linked list  how to implement stack using linked list
Creating List in Java using SWT
Creating List in Java using SWT       This section illustrates you how to create a list of certain items using the Standard Widget Toolkit In this example, we have create a list
Java Iterator with Example
Iterator is an interface in the collection framework It traverses through... hasNext() and next(). Java Iterator Example import java.util.*; public class iterator { public static void main(String[] args
Iterator Java Tutorial
methods hasNext() and next(). List, Set interface has iterator() methods . Example of Java Iterator import java.util.*; public class iterator1... Java Iterator is an interface in the collection framework It traverses
J2ME List Image
J2ME List Image       List Image MIDlet Example This example illustrates how to create list with image symbol. In this example we are trying to create list using of List class
How to solve this java code by adding the student marks not in the list of the table. For example -10 and 156 in GUI?
How to solve this java code by adding the student marks not in the list...; a++) { String input=JOptionPane.showInputDialog(null,"Please insert student...; marks >= 100) { data[a].setGrade("Not in the list of the table
upload file and insert other details to database using a single form
upload file and insert other details to database using a single form   hi.. I have problem with uploading a file and insert other user datas together... but my other details seem to be null
Advertisements
 

 

 

DMCA.com