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



Home Answers Viewqa Development-process Real Time code for Array list
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Rajendra
Real Time code for Array list
1 Answer(s)      5 years and 4 months ago
Posted in : Development process



Advertisement
View Answers

July 22, 2009 at 4:21 PM


Hi Friend,

Try the following code:

import java.util.*;

class Student {
public Student(String n, double s, int year, int month, int day){
name = n;
marks = s;
GregorianCalendar calendar = new GregorianCalendar(year, month - 1, day);
admissionDate = calendar.getTime();
}
public String getName(){
return name;
}
public double getMarks(){
return marks;
}
public Date getAdmissionDate(){
return admissionDate;
}
public void raiseMarks(double p){
double raise = marks * p / 100;
marks += raise;
}
private String name;
private double marks;
private Date admissionDate;
}
public class ArrayListExample{
public static void main(String[] args){
ArrayList<Student> student = new ArrayList<Student>();
student.add(new Student("A", 90, 2001, 10, 15));
student.add(new Student("B", 95, 2002, 7, 1));
student.add(new Student("C", 85, 2003, 4, 15));
student.add(new Student("D", 80, 2004, 8, 1));
for (Student s : student)
s.raiseMarks(5);
for (Student s : student)
System.out.println("Name=" + s.getName() + " Marks=" + s.getMarks() + " Admission Date="+ s.getAdmissionDate());
}
}

Hope that it will be helpful for you.
Thanks


Related Tutorials/Questions & Answers:
Real Time code for Array list - Development process
Real Time code for Array list  Hi, Can u give me sample code for Arraylist in real time applications. Thanks PraKash  Hi Friend, Try the following code: import java.util.*; class Student { public
real time question
real time question  can you just give me the example of using hibernate in DAO classes   Hi Friend, Please visit the following link: Hibernate Tutorials Thanks
Advertisements
Array list java code - Java Beginners
Array list java code  Create an employee class with an employee id's,name & address. Store some objects of this class in an arraylist. When an employee id is given, display his name & address? Please provide the DETAIL java code
Array list java code - Java Interview Questions
Array list java code  Create an employee class with an employee id's... an employee id is given, display his name & address? Please provide the DETAIL java code... in your code?Please clarify it. Thanks  i need the java code
Real time examples - Java Beginners
Real time examples  what is method overloading,method overriding,constructor overloading concept in java and explain with real time examples? .../javascript-array/modified-java-method-overriding.shtml http://www.roseindia.net/java
Real Time Scenarios - Development process
Real Time Scenarios  Hello, Can anybody tell me regarding the Quality Processes that are to be followed while developing an application using struts/ejb ?  Hi The Quality Process is totally depend on the quality
array list
array list  How to get repeate occurence values from database table in java by using arraylist
Array List
Array List   Complete the class House and HouseApp below to display class House{ int lotNo; String type; //Bungalow, SemiDetached double price; public House ( int l, String t, double p) { â?¦ } public int theLotN() {
Array List
Array List  Could somebody help me to solve this question. I am glad to hear ideas or answers from everyone. The situation: Complete the class House and HouseApp below to display class House{ int lotNo; String type
Displaying database table on the windows screen in real time.
Displaying database table on the windows screen in real time.  Problem statement... I have a database table which is running on a remote host .I... can give the code for this. Thank u
Real Time Mobile Tracking
Real Time Mobile Tracking Real time mobile tracking is all about being able... technology. Real time mobile tracking is a web-based solution that helps in attaining... in real time using the GSM/GPRS technology by gathering data in the process about
what is the use of clone() in real time scenario?
what is the use of clone() in real time scenario?  what is the use of clone() in real time scenario?   Hi Friend, Clone() method is used to create and return copy of the object. For more information, visit
array list example
array list example  Array list example   Hello Friend, Please visit the following links: Array List Example1 Array List Example2 Thanks
Real Time GPS Fleet Tracking
efficiency, logistics companies need the real time fleet management solution. The real time fleet tracking solution helps the companies to exactly pin pointing... of the investments done by the logistics companies in installing real time GPS fleet tracking
getting html list in a array
getting html list in a array  hi i want to get html unordered list in a array using jsp
getting html list in a array
getting html list in a array  hi i want to get html unordered list in a array using jsp
Java ArrayList, Java Array List examples
of the List interface. It has support for all the functions present in the List interface... the ArrayList in Java with the example code. SampleInterfaceImp.java import... ArrayList list = new ArrayList(); // Adding Element to the ArrayList Object
Real-time GPS fleet Management
Fleet business depends on real-time GPS fleet management. Now to make it clear... destination and also helps him in avoiding traffic and accidents. Real-Time GPS... and store data regularly and in real time so that the person gets updated
Array List and string operation
Array List and string operation  hi, I want to search an arraylist element in a a given file. example I have a name called "mac" in my arraylist... file. please give me the code
Real Time Example Interface and Abstract Class - Java Beginners
Real Time Example Interface and Abstract Class  Hi Friends, can u give me Real Time example for interface and abstract class.(With Banking Example
array of students with marks list
array of students with marks list  There are 4 array of numbers or scores as below. They are called marks list and represent the scores individual... across all lists and also the number of students (4 in this case). Marks List 1
Real time Mechanism fot Sessio Tracking - Servlet Interview Questions
Real time Mechanism fot Sessio Tracking   Hi Friends, Which is d most commonly used mechanism for tracking a session. and y it is best . thanks in advance
Convert List to Array
Convert List to Array       Lets see how to convert List to ArrayCode Description... a method Mylist.toArray to convert the List to Array. Here is the code
Convert Array to List
Convert Array to List       In this section, you will learn to convert an Array to ListCode Description: This program helps you in converting an Array to List. Here we
Online Real-Time GPS Phone Tracking Service
Online Real-Time GPS Phone Tracking Service Online Real-Time GPS Phone... to track, trace and monitor mobile phones in real time. There are number of types... for tracking phone devices thus has real-time benefits. A basic unit can has
What is RTLS or Real Time Location System?
RTLS or Real Time Location System is a positioning system that acquired new... for incorporating many other features. RTLS or Real Time Positioning System compared... tracking system is an active real time based solution that can use radio frequency
Shuffling the Element of a List or Array
Shuffling the Element of a List or Array   ... the list or array to prepare each and every element for the operation. In this section, you will learn about shuffling the element of a list or array. Shuffling
PHP list array
Array Code for PHP List Array <?php     $stud = array(1... Syntax for PHP List Array void list(var arg1,var arg2,var arg3) list() is used to assign many variables at a time. It takes variable values from
Time series sorce code
Time series sorce code   hi.......... I want to show the output of my project as time series. Can u give me a simple code for time series. Where i amble able to put on x-axis the date and y-axis the range.? I require the time
Time series sorce code
Time series sorce code   hi.......... I want to show the output of my project as time series. Can u give me a simple code for time series. Where i amble able to put on x-axis the date and y-axis the range.? I require the time
Array list in Java - arraylist type error
Array list in Java - arraylist type error  I am using Array list in Java but when i compile i get array list type error. Can anyone please explain what is array list type error and why it occurs
 

 

 

DMCA.com