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 linked list. The problem is I don't know how to create patient object. Can someone help me?

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
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
data types
data types  Write a short note on data types of Java.   Please visit the following link: Java datatypes
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
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
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
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
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
Hibernate Data types
This section lists Hibernate data types
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
Data types in a table
Data types in a table  hii, What are the data types allowed in a table?   hello,,ADS_TO_REPLACE_1 These are the data types in table..._TO_REPLACE_2 These are the data types in table:- VARCHAR2, CHAR, NUMBER, RAW
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
PHP search data with different format
PHP search data with different format  How to search data with different format in PHP
Data Types in Java 7
In this section we will discuss Java 7 Data Types
Reference Data Types
Reference Data Types      ...;Reference Data Types Lets have a discussion about Reference Data Types in brief ADS_TO_REPLACE_1 In Java a reference data type
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
Java Data Types
Java Data Types      ... on it. There are seven more primitive data types which are supported by Java language... is predefined in Java. Following are the eight primitive data types: int It is a 32-bit
ModuleNotFoundError: No module named 'data-object'
ModuleNotFoundError: No module named 'data-object'  Hi, My Python... 'data-object' How to remove the ModuleNotFoundError: No module named 'data-object' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'data-object'
ModuleNotFoundError: No module named 'data-object'  Hi, My Python... 'data-object' How to remove the ModuleNotFoundError: No module named 'data-object' error? Thanks   Hi, In your python environment
Python variables and data types
Python Tutorials: Learning variables and data types in Python with examples The variables and data types are essential topics in Python programming language. Programmers should learn to use various data types in Python Programming
Python variables and data types
is an object and data types are instance of classes. Variables are instance (object...Python Tutorials: Learning variables and data types in Python with examples The variables and data types are essential topics in Python programming language
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
object oriented programming data science
object oriented programming data science  Hi, I am beginner in Data...: object oriented programming data science Try to provide me good examples or tutorials links so that I can learn the topic "object oriented programming
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-ADS_TO_REPLACE_1 binary Bigint bit Char datetime
Types of Outsourcing,Different Types of Outsourcing,Types of Outsourcing Services
Different Types of Outsourcing Introduction..., call center, DTP, data entry, proof reading and editing, typesetting, handwriting... property research, animation and simulation. Data research and analysis, legal
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
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
What are the different types of interfaces in java? - Java Interview Questions
What are the different types of interfaces in java?  Hi, Is it correct question.I faced this in one interview. If yes can u tell me please. thanks chandu
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
Flex 3 data binding process and example
Data binding in Flex 3:- Data binding is a process to pass data from one object to another object and is a process to pass data between different layer.... Flex 3 provide three types of data binding: 1. Curly braces ({}) data
Know the Different Types of E-Commerce
Know the Different Types of E-Commerce There are different types of e-commerce and we need to know what e-commerce is and how different it is from e... can send across different kinds of files and information which can
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
Data Access Object
Creating Data Access Object (DAO) Design Pattern The Data Access Object is a design pattern, which consists java classes and methods to access the data. It provides a technique to separate the object persistence and data access logic
ModuleNotFoundError: No module named 'algebraic-data-types'
ModuleNotFoundError: No module named 'algebraic-data-types'  Hi...: No module named 'algebraic-data-types' How to remove the ModuleNotFoundError: No module named 'algebraic-data-types' error? Thanks   Hi
ModuleNotFoundError: No module named 'data-science-types'
ModuleNotFoundError: No module named 'data-science-types'  Hi, My... named 'data-science-types' How to remove the ModuleNotFoundError: No module named 'data-science-types' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'data-science-types'
ModuleNotFoundError: No module named 'data-science-types'  Hi, My... named 'data-science-types' How to remove the ModuleNotFoundError: No module named 'data-science-types' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'algebraic-data-types'
ModuleNotFoundError: No module named 'algebraic-data-types'  Hi...: No module named 'algebraic-data-types' How to remove the ModuleNotFoundError: No module named 'algebraic-data-types' error? Thanks   Hi
ModuleNotFoundError: No module named 'data-science-types'
ModuleNotFoundError: No module named 'data-science-types'  Hi, My... named 'data-science-types' How to remove the ModuleNotFoundError: No module named 'data-science-types' error? Thanks   Hi, In your
Primitive Data Types
Primitive Data Types In java, all the variables needs to be declared first... below : Java Data Types.... The value assigned to a variable determines its data type, on which the legal
Different types of exception handling in Java
Different types of exception handling in Java Mostly an error or exception in java occurs due to programming error, client code error or due to resource... and types of exceptions in Java. There are basically two types of errors , compile
Different types of event in Java AWT
Different types of event in Java AWT       Introduction There are many types of events... effective and efficient. Generally, there are twelve types of event are used
inserting same data to different tables in oracle
inserting same data to different tables in oracle  Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracle
inserting same data to different tables in oracle  Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracle
inserting same data to different tables in oracle  Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can

Ads