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



Home Answers Viewqa Java-Beginners Object with different data types
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Aung Ye
Object with different data types
1 Answer(s)      a year and 9 months ago
Posted in : Java Beginners


Hello,

I need to build a "patient" object that can contain String "name", String "ID", double "weight" and Date "birthDate". Then that object is referenced to the linked list. I know how to use linked list. The problem is I don't know how to create patient object. Can someone help me?


Advertisement
View Answers

March 29, 2013 at 5:49 PM


hi,

Perhaps, you are looking for the code like below :

package net.roseindia;

import java.util.LinkedList;
import java.util.Iterator;
import java.util.List;
public class Patient {
    String name;
    String id;
    double weight;  

    public Patient(String name, String id, double weight) {
        super();
        this.name = name;
        this.id = id;
        this.weight = weight;       
    }

    public String getName() {
        return name;
    }

    public String getId() {
        return id;
    }

    public double getWeight() {
        return weight;
    }

    public Patient getPatient()
    {
        return  new Patient(name, id, weight);
    }

    public static void main(String args[])
    {
        Patient patient = new Patient("Ankit", "15", 45.85);
        Patient patient1 = new Patient("Bipul", "16", 50.85);
        Patient gPatient = patient.getPatient();
        Patient gPatient1 = patient1.getPatient();
        List list = new LinkedList();       
        list.add(gPatient.getId()+" "+gPatient.getName()+" "+gPatient.getWeight());
        list.add(gPatient1.getId()+" "+gPatient1.getName()+" "+gPatient1.getWeight());
        Iterator itr = list.listIterator();
        while(itr.hasNext())
        {
            System.out.println(itr.next());
        }       
    }
}


Related Tutorials/Questions & Answers:
Object with different data types
Object with different data types  Hello, I need to build a "patient" object that can contain String "name", String "ID", double "weight" and Date "birthDate". Then that object is referenced to the linked list. I know how to use
size of different basic data types
size of different basic data types   Write a simple program to find the size of different basic data types in java
Advertisements
Conversion from string data type into different data types.
Conversion from string data type into different data types.  string str="World id Beutifull"; char chr[20]; char* chrctr ; Qustion is -How to store the 'str' value in 'chr' and 'chrctr'? int abc; sprintf(abc ,"%s",str
What are the different types of AutoProxying?
What are the different types of AutoProxying?  Hi, What are the different types of AutoProxying? Thanks
data types
data types  Write a short note on data types of Java.   Please visit the following link: Java datatypes
WHAT ARE THE DIFFERENT TYPES OF ERRORS IN PHP?
WHAT ARE THE DIFFERENT TYPES OF ERRORS IN PHP?  WHAT ARE THE DIFFERENT TYPES OF ERRORS IN PHP
different types of storage devices of a computer
different types of storage devices of a computer  What are the different types of storage devices of a computer?   Magnetic disks, Tapes and DVDs are few examples of storage devices of a computer
Different types of web hosting services
Different types of web hosting services  Hi, There are many.... I was browsing their websites but still could not understood the different types of web hosting services. Can anyone explain me different types of web hosting
Numeric Data Types
Numeric Data Types  Compare numeric data types of java with corresponding data types in C
JavaScript Data Types
JavaScript Data Types  What are JavaScript Data Types
Data types in a table
Data types in a table  hii, What are the data types allowed in a table?   hello,, These are the data types in table:- VARCHAR2, CHAR, NUMBER, RAW, DATE, LONG and LONG RAW.   hello,, These are the data
What is a join and explain different types of joins
What is a join and explain different types of joins  What is a join and explain different types of joins?   Hi, Joins are used in queries to explain how different tables are related. Joins also let you select data from
Hibernate Data types
This section lists Hibernate data types
What are the different types of property and class mappings?
What are the different types of property and class mappings?  Hi, What are the different types of property and class mappings? thanks
Are arrays primitive data types?
Are arrays primitive data types?   Hi, Are arrays primitive data types? thanks   Hi, In Java, Arrays are objects. Identifier are some... as primitive data type
What are constructors ? explain different types of constructor with example
What are constructors ? explain different types of constructor with example  Hi, What are constructors ? explain different types of constructor...;Hi, For creating a new instance or a new object of class we using
Declaring Data Types in Java
Declaring Data Types in Java  What is the best way of declaring data types in Java?   http://www.roseindia.net/java/master-java/java-data... named 'byteident' which primitive data type is byte."); System.out.println
Data Types in Java 7
In this section we will discuss Java 7 Data Types
Java Data Types
Java Data Types      ... more primitive data types which are supported by Java language programming.... Following are the eight primitive data types: int It is a 32-bit signed two's
Reference Data Types
Reference Data Types      ...;Reference Data Types Lets have a discussion about Reference Data Types in brief In Java a reference data type is a variable that can
demonstrating understanding of data types
demonstrating understanding of data types  Design and implement a Java program that will gather a userÔ??s first name, middle initial, lastname, age in years, and 3 lucky numbers. The program should output the following based
java parsing of data types
java parsing of data types  Why its not works? char ch; String s=* ch=Character.parseChar(s) program: char op; DataInputStream dis=new DataInputStream(System.in); System.out.print("Enter operator (+,-,*,/,%): "); op
What are the data types allowed in a table?
What are the data types allowed in a table?  What are the data types allowed in a table?   Hi, The data types allowed in a table are as follows- binary Bigint bit Char datetime decimal Float
Primitive Data Types
In this section we will discuss about Primitive Data Types in Java 7
Reference Data Types
In this section we will discuss about Reference Data Types in Java 7
Types of Outsourcing,Different Types of Outsourcing,Types of Outsourcing Services
Different Types of Outsourcing Introduction..., book keeping, business consultancy, CAD/ CAM, call center, DTP, data entry... and simulation. Data research and analysis, legal services, content writing
PHP Data Types
Data Types in PHP:  In programming language there are two types of data: atomic data and composite data, atomic data are those which can not broken further and composite data are just the opposite and it can be broken further
Data types in Oracle 9i - SQL
Data types in Oracle 9i  Cn anyone tell me the difference between timestamp wih time zone and timestamp with local timezone datatypes in oracle 9i.  Hi Friend, On Using TIMESTAMP WITH TIME ZONE, oracle store timezone
Primitive Data Types
Primitive Data Types In java, all the variables needs to be declared first... Data Types.... The value assigned to a variable determines its data type, on which the legal
PHP search data with different format
PHP search data with different format  How to search data with different format in PHP
Data Access Object
Data Access Object  Hi sir/madam please give me some tutorial/example about Data Access Object   Hi Please Find the example of Java Data Access Object http://www.roseindia.net/tutorial/java/jdbc
Advertisements
 

 

 

DMCA.com