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 5 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:
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 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
Advertisements
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
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
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
Flex Data Types
. Primitive Data types: int, uint, Number, Boolean, String, Null and void Complex Data types: Array, Date, Error, Function, RegExp...: #FFFFCC; } The data type of the variable defines the type of the value
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
Data transfer object at run time - Development process
Data transfer object at run time  I have to assign data from resulset to data transfer object.. but i don't know the the number of coloums in selected table. So i have creted a Data Object class with 100 getter setter methods
PHP Boolean Data Types
PHP Boolean Data Type: Boolean is one of the simplest data type supported.... For conversion to boolean data type, we need to use (bool) or (boolean) casts. Though... converts. Example of PHP Boolean Data Type : <?php $a=23; var_dump
JDOM Attribute Example, How to convert value of attribute in different data type
JDOM Attribute Example, How to convert value of attribute in different data type In this tutorial, we will see how to retrieve the value of an attribute in different data type like int, float, boolean etc with the help of JDOM
Types of Servlet
Types of Servlet  What are the types of Servlet ?   There are two types of servlets, GenericServlet and HttpServlet. GenericServlet defines the generic or protocol independent servlet. HttpServlet is subclass
Types of Triggers
Types of Triggers   hii, How many types of Triggers in sql?   hello, there are three type of trigger DML triggers Instead of triggers System triggers
Types of Web Hosting
Types of Web Hosting There are different types of web hosting services... classify the types of web hosting service system, according to: 1. Operating... types of Web Hosting A. DNS Hosting B. Game Server Hosting C. E-mail hosting
Indexed Vector Array in Action Script 3.0
array class instance with different data types. Example:- <... or insert in the array. After that we have insert values that have different data types with the help of access operator and after that we have access that array
types of relationships in tables
types of relationships in tables  How to implement one-to-one, one-to-many and many-to-many relationships while designing tables?   hi... are implemented by splitting the data into two tables with primary key and foreign
Types of JDBC drivers
of JDBC Driver into the ODBC query, which in return pass the data. 2.JDBC-ODBC... of different environment. 3.The JDBC Client driver written in java, communicates... for different database at middleware. 2.Due to extra layer in middle can result in time
PHP Clone Object
of the original one, the process of cloning in PHP 5 is quite different from PHP 4, in the earlier version of PHP all we need to do is to assign an object to another object. But in the latest version of PHP, clone construct along with a magic
ENUM Types
ENUM Types A Enum type consist of a fixed set of constants. In java, you define an enum type by using the enum keyword. For example, you would specify a months-of-year enum type as: public enum Year{ January,February,March
Session Object
. The session object is used by the developers to store and retrieve user's related data such as login details. The javax.servlet.http.HttpSession object...Session Object  Why do we require Session Object?  Hello
Copying and Moving data using drag and drop
Copying and Moving data using drag and drop: You can drag and drop the data from list to dataGrid using different data formats in this example. When you move data and add it to the drop target it will be removed from draginitiator
different kinds of actions in Struts
different kinds of actions in Struts  What are the different kinds of actions in Struts
different JDBC drivers available
different JDBC drivers available  What are the different JDBC drivers available
Track user's session using 'session' object in JSP
Track user's session using 'session' object in JSP This section is about tracking user identity across different JSP pages using 'session' object. Session Tracking : Session tracking is a mechanism that is used
Introduction to Data Structures
Data Structure in C A memory play a vital role in c because all variable you... Data Segment Free Space Stack Segment  Data..., Stacks, Queues, Trees, and Graphs which are related with the data structures
PDO Fetch Object
PDO Fetch Object: This is another way to access the data of a table, accessing fields as object. By using this  method we get the result set as anonymous object and this object represents the field names of the table as object
links with different colors.
links with different colors.  How can I have two sets of links with different colors
Vector object[]
Vector object[]  I want to create payslip in java public Vector...(); Object[] value = new Object[] {"Employee Name",f.ename.getSelectedItem()}; rec.add(value); value = new Object[] {"Mary-Kate Olsen", "Ashley
What are different normalization forms?
What are different normalization forms?  What are different normalization forms?   Hi, 1NF: Eliminate Repeating Groups- Make a separate... Redundant Data- If an attribute depends on only part of a multi-valued key, remove
PHP Boolean Variables
PHP Variables Boolean In PHP we have different kinds of data types such as integers, float, character, double and so on. There are one logical data type which is called Boolean data type. It is a primitive data type having either true
JTable hold different components
JTable hold different components  create Jtable with two coloums,one coloumn is combobox and other normal
PHP Class Object
PHP Class Object: In object oriented programming a class can be an abstract data type, blue print or template. You could consider the name of a class as noun... apple, orange are the object of this class. Object is the instantiate
Object creation - Ajax
Object creation  How we want to create an object that directly get data from server
Autoboxing/unboxing of primitive types
Autoboxing/unboxing of primitive types When adding a primitive data type,conversion between primitive types and wrapper classes is necessary ...;In Boxing  ,it converts primitive values to wrapper types:  if p is a value
different between ntfs and fat
different between ntfs and fat   hello, what is the different between ntfs and fat ???   hello, The major difference between FAT and NTFS is security. If you have FAT partition then Security and Quota tap
Java object
Java object  Which class should you use to obtain design information about an object
class and Object
class and Object  how many classes,References and objects in this following statement.... A a=new B();   Hi, In the statement: A a=new B(); There are 2 classes, Class A and Class B. References : 1 (Object of B
implect object
implect object  how i implment implect object   Hi Friend, Please visit the following links: http://www.roseindia.net/help/java/o/jsp-implicit-objects.shtml http://www.roseindia.net/jsp/jspfundamentals.shtml Thanks
Class and object
the object of subclass Thanks
JSP Response Object
JSP Response Object  JSP response Object ?   The response object denotes the HTTP Response data. The result or the information of a request is denoted with this object. The response object handles the output
html page viewed on different os
html page viewed on different os  The colors on my page look different when viewed on a Mac and a PC
Set Different Color to different row in Java Program
Java Set Different Color to different row In this section, you will learn how to set different color to table row using java swing.For this purpose, we have.... This class provides the method setBackground() which allow us to set different
JSP Application Object
JSP Application Object  JSP Application Object?   Application Object is used to share the data with all application pages. Thus, all users share information of a given application using the Application object
JSP Session Object
JSP Session Object  JSP Session Object?   Session Object denotes the data associated with a specific session of user. The class or the interface name of the object session is http.HttpSession. The object session
object - Java Interview Questions
object  hi, what are the different ways of creating objects?   Hello, i know only two wayes of object instansiations 1.... Thankx   Hi Friend, Yes we can create an object in the following
java object - Java Beginners
of objects. The primitive data type and keyword void is work as a class object. Object: Object is the basic entity of object oriented programming language... their objects. Object is an instance of the class. It takes the properties (variables
help regarding variable types and its modifiers
help regarding variable types and its modifiers  static variable is initialized once only and can be used by all objects. i want static in sense of program execution i want to count how many times the said program is executed
different execution time - Java Beginners
different execution time    hello, when i run the bellow code more than one time i am getting different execution time("Total time taken"), Ex. when i run first time it prints Total time taken 47 second time it prints Total
data structures - Java Beginners
data structures  I have got a project of the subject 'data structures and C++' and the topic is 'types of graphs'. please guide me on this topic and help me finding material of this topic
 

 

 

DMCA.com