dcsimg
NOT A GURU HERE !! NEED EASY HELP on EASY QUESTION.
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   weber_hsu
Posted On:   Monday, September 30, 2002 12:03 AM

public class Database { public Object[] service_array; public void Database(String service, String host, String port){ service_array = new Object[3]; service_array[0] = service; service_array[1] = host; service_array[2] = port; } } How do I call that class above into another class in the same physical folder? Does that code even make sense?? I get an error when in the other class I try: Database("hi", "bye", "123"); Thanks, a very simple question. sorry for bothering you!    More>>

public class Database {

public Object[] service_array;

public void Database(String service, String host, String port){

service_array = new Object[3];

service_array[0] = service;

service_array[1] = host;

service_array[2] = port;

}

}








How do I call that class above into another class in the same physical folder?



Does that code even make sense??


I get an error when in the other class I try:

Database("hi", "bye", "123");




Thanks, a very simple question. sorry for bothering you!

   <<Less

Re: NOT A GURU HERE !! NEED EASY HELP on EASY QUESTION.

Posted By:   Gergely_Dombi  
Posted On:   Monday, September 30, 2002 12:51 AM

You sholdn' t give a return value to the constructor.
It is not an ordinary method. So try this:

public class Database {
public Object[] service_array;
public Database(String service, String host, String port){
service_array = new Object[3];
service_array[0] = service;
service_array[1] = host;
service_array[2] = port;
}
}

Now myDB = new Database("hi", "bye", "123"); will
compile from the same folder.

Re: NOT A GURU HERE !! NEED EASY HELP on EASY QUESTION.

Posted By:   Manish_Marathe  
Posted On:   Monday, September 30, 2002 12:44 AM

Hi There,



The visible problem is


Your constructor has Return type void which is wrong. Constructor should not have any return type.



If you just remove the "void" from your Constructor declaration, it should work fine!



Enjoy!



- Manish
About | Sitemap | Contact