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



Home Answers Viewqa Java-Beginners Object with different data types

Have Programming Question? Ask it here!
 
 
 


Aung Ye
Object with different data types
1 Answer(s)      a year and 4 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
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
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
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
Doubt on Data Types - Java Beginners
Doubt on Data Types  Hi Friend doubt on DataTypes... How should i declare n Assign value to the Float variable; Can u Please COMPILE this Program...Explain in detail
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
Java Data Types
Java Data Types      ... and then to be used. Java support eight types of primitive data types. Primitive data types are the data types already defined in Java. Following are the eight
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
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
Mapping MySQL Data Types in Java
Mapping MySQL Data Types in Java       Data types of MySQL and Java programming language... using MySQL data types and a application using Java data types. We need to provide
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
Passing Various Data Types into Cells
passing various data types into cells   ... data types into the cells and rows in the excel sheet using java .You can... types into cell by using this method. In this example, we have used four data types
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
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
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
Set Data Types by using Prepared Statement
object. Now,  we will set all data types like String, int, double and float... Set Data Types by using Prepared Statement   ... the method for setting data types (String, int, float and double
Set byte, short and long data types by using the Prepared Statement
object. Now, we will insert different types of data like: byte, short and long... Set byte, short and long data types by using the Prepared Statement...; This tutorial teaches you the process of setting the byte, short and long data types
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
Java Data Types
Java Data Types      ...-typed programming language. The data types in the Java programming language...;  Reference Data Types  Primitive Data Types 
 

 

 

DMCA.com