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



Home Answers Viewqa Java-Beginners How to return multiple values from a method
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Ed
How to return multiple values from a method
0 Answer(s)      4 years and 5 months ago
Posted in : Java Beginners


I came the following method "How do I return multiple values from a method?" posted elsewhere. The problem is that I wanted to tested the method posted, but I am getting the incorrect result. Can someone tell me how my Driver.java program [see below] should be coded?


public class UserName {
protected String ivFirstName, ivLastName;

public UserName(String first, String last) {
ivFirstName = first;
ivLastName = last;
}

public String getFirstName() {
return ivFirstName;
}

public String getLastName() {
return ivLastName;
}
}


public class User {
protected String ivFirstName = "Java";
protected String ivLastName = "Developer";

/**
* This is returning a single Object, which contains
* multiple values.
*/
public UserName getName() {
return new UserName(ivFirstName, ivLastName);
}
}


// This is my Driver.java program to test the method posted.
// The result I got was: UserName@7d8a992f
//
public class Driver {
public static void main (String[] args) {
User method = new User();
System.out.println(method.getName());
}
}






Advertisement
View Answers

Related Tutorials/Questions & Answers:
How to return multiple values from a method - Java Beginners
How to return multiple values from a method  I came the following method "How do I return multiple values from a method?" posted elsewhere..."; /** * This is returning a single Object, which contains * multiple values
How to return multiple values from a method - Java Beginners
How to return multiple values from a method  I came the following method "How do I return multiple values from a method?" posted elsewhere..."; /** * This is returning a single Object, which contains * multiple values
Advertisements
Java Method Return Multiple Values
Java Method Return Multiple Values In this section we will learn about how a method can return multiple values in Java. This example explains you how a multiple values can be return by a method. This example explains you all
How to pass multiple values from a servlet to JSP?
How to pass multiple values from a servlet to JSP?  hi, I want to pass multiple values form a servlet to JSP. Hw do i do that? I am able to send one value at a time without any prb, but I am unable to carry multiple (from two
How to carry multiple values from a Servlet to a JSP?
How to carry multiple values from a Servlet to a JSP?  By using...). ----response.sendRedirect("index.jsp?uname="+username);---- But I want multiple values needs to be carried from my servlet to a JSP. How do I do
Regarding method returns multiple values
Regarding method returns multiple values  Hi, 1)I have a requirement like,1 method returns multiple values.how to do that one. 2)can i use method, for example like getFile()[] in this way or not. plzzzzzzzzzzzzzzzzzz provide
how to store multiple values from drop down in database where i am using java struts 1.3
how to store multiple values from drop down in database where i am using java... is displaying.. i need code in java so that it takes multiple values... where i have to select multiple keyskills. but it is taking only one valuee.. i
How to return a string from a JTextField
How to return a string from a JTextField  Hi, Am new to java, and am trying to get a string from a JTextField so that I can compare it with another.... The problem is i have no clue how to get the very string i need because i think
how to get multiple hyperlink values from a table column to another jsp file?
how to get multiple hyperlink values from a table column to another jsp file... file named "dbtable" will get the parameter from "index" and search... show the specific details from that hyperlink which was clicked. there are 3
retrieve multiple columns values from multiple csv files in java
retrieve multiple columns values from multiple csv files in java  Suppose there is folder in C:\fileupload which contains these two csv files...)///// here VendorID is corresponding to file1.csv i want to retrive data from
Passing java variables from JSP to Servlet - return null values
Passing java variables from JSP to Servlet - return null values  I want to pass some variables from a JSP page to a servlet. These variables are from... from JSP to servlet gives null values. I got msg=null. Is there another way
calling a javascript function by passing multiple values from applet in web application
calling a javascript function by passing multiple values from applet in web application  Hi all, I have a requirement like this, I have to call a javascript function from JApplet by passing 3 values. I am new to Applets
select tag multiple values
select tag multiple values   I want to insert multiple values in database which i have selected from select tag
@SessionAttributes multiple values
@SessionAttributes multiple values In this section we will see how you can use @sessionattributes to set multiple session values to it. While developing... and someCombobox. The correct way to use @sessionattributes for multiple values
PHP Returning Values from Function
Returnig Values from function: From a function we can return values using optional return statement, in PHP we can return arrays, objects. With the help of the return statement the control moves back to the calling portion
Java Method Return Value
Java Method Return Value       Java  method Return Value return to the code when... the value within the body of method. The method declared void does not return any
how to read values from java in xml?
how to read values from java in xml?  how to read values from java in xml
multiple select values
multiple select values   can you provide an example for multiple select values for html:select tag
how to insert values from jsp into ms access
how to insert values from jsp into ms access   how to insert values using jsp into ms access database
How to get Keys and Values from HashMap in Java?
How to get Keys and Values from HashMap in Java? Example program of iterating... through keys and get the values from a HashMap object. The entrySet() method... to iterate the keys and get the values and print on the console. How to get keys
how to fetch values from .properties to a html file
how to fetch values from .properties to a html file  I have a .properties file with some key value pairs in it. I need to fetch the values from this .properties file into a html file.Please let me know how to do
PHP Functions and Return values
PHP Functions and Return values A function is the a block of code whom you can... need it. To protect the script from being auto executed on page load , we put... to the function. You may call these function from any where within page. Syntax
How to values from xml using java?
How to values from xml using java?  Hi All, I want to read value from following < Line> xml using java.. In < Line>,data is in format of key and value pair.. i want to read only values..could u plz help me
How to Display values from databse into table
How to Display values from databse into table  I want to display values from database into table based on condition in query, how to display... enter either bookname or authorname and click on search button the values from
how to get a values from processRecord - JSP-Servlet
how to get a values from processRecord  dear sir, i have a problem in getting a values from java to jsp.Here jsp is used to read a excel sheet that intern call a java program so i want a column values i.e a column contains
What is the return type of the main method?
What is the return type of the main method?  hi, What is the return type of the main method? thanks   Hi, In the java programming the Main() method doesn't return anything hence declared void. In Java, you need
How to create file from input values in Jframe ?
How to create file from input values in Jframe ?  hi i m doing my project using java desktop application in netbeans.i designed a form to get the user's academic details and on clicking the submit button,it displays all
retrieve multiple attribute values
XML retrieve multiple attribute values  Hello All Am a beginner. Would like some help with this. The following is part of my XML file: <...; What I would like is to retrieve both the attribute values of process
retrieve multiple attribute values
retrieve multiple attribute values  Hello All Am a beginner. Would like some help with this. The following is part of my XML file: <process... like is to retrieve both the attribute values of process:Output during execution
retrieve multiple attribute values
retrieve multiple attribute values  Hello All Am a beginner. Would like some help with this. The following is part of my XML file: <process... like is to retrieve both the attribute values of process:Output during execution
how to get the values to dropdownlist from oracle database
how to get the values to dropdownlist from oracle database   </script> </head> <body> <select name... * from countryname"); while(rs.next()){ %> <option value="<
Advertisements
 

 

 

DMCA.com