GIDForums  

Go Back   GIDForums > Computer Programming Forums > Java Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 02-Apr-2008, 12:04
moody moody is offline
New Member
 
Join Date: Mar 2008
Posts: 22
moody has a little shameless behaviour in the past

Need help with java arguments


Hello!

I need some help passing a second argument introduced in the output(Netbeans) to a string,so I can then pass it to the constructor.Something like this:

new <title> name.txt

What I need to to do is pass the title to the constructor.How can i do this?
  #2  
Old 08-Apr-2008, 04:02
mamntc02 mamntc02 is offline
Junior Member
 
Join Date: Mar 2008
Location: Barcelona - Catalonia
Posts: 53
mamntc02 has a spectacular aura about

Re: Need help with java arguments


Hi,
JAVA Code:
public class ClassName{
	private String title;
	public ConstructorName(String title){
		this.title = title;
	}
}
So, in the class where you create an instance of this class:
JAVA Code:
....
String title = "MyTitle";
ClassName className = new ClassName(title);
...
Regards
__________________
Please, correct me if I'm wrong, and sorry for my english ;)
  #3  
Old 25-Apr-2008, 13:29
JustinFox JustinFox is offline
Junior Member
 
Join Date: Mar 2008
Posts: 59
JustinFox will become famous soon enough

Re: Need help with java arguments


Make sure to create getter and setter methods for that class as well. You never know if you're going to want to update or retrieve that title later on.

Justin Fox

Example:

JAVA Code:

private String getTitle()
{

return title;

}

private Boolean setTitle(String newtitle)
{
boolean success = true;
try
{
title = newtitle;
}
catch(Exception e)
{
System.out.println("Error while setting new title");
success = false;
}

return success;

}




Justin Fox
 
 

Recent GIDBlogMeeting the local Iraqis by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the equivalent in Java for a Function or Module in VB pengwinz Java Forum 2 17-May-2007 20:02
To post messages / click Buttons of a Java Jar App using code Jun0 C Programming Language 1 06-Jan-2007 14:44
To post messages / click Buttons of a Java Jar App using code Jun0 Java Forum 0 06-Jan-2007 11:14
Scalability in Java and C++ agx Miscellaneous Programming Forum 7 04-Feb-2006 15:35
Made program in Java, trying C++ now, file i/o problems technickel C++ Forum 4 19-Feb-2005 00:32

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 20:34.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.