Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > calling from another classwhy isn't oneSite not applied to int

Thread Tools

calling from another classwhy isn't oneSite not applied to int

Jucy Love
Posts: n/a
this is the first file called
public class EventSite3
private int siteNumber;
public int getSiteNumber()
return siteNumber;
public void setSiteNumber(int n)
siteNumber = n;

this is the second file called
public class SetUpSite5
int currentYear = 2003;
int age;
EventSite3 oneSite = new EventSite3();
int number;

public void statementOfPhilosophy()
age = calculateAge(currentYear);
number = oneSite.getSiteNumber();
System.out.println("Serving you " + age + " years");
System.out.println("The number of the event site is " + number);
System.out.println("Event Handlers Incorporated is");
System.out.println("dedicated to making your event");
System.out.println("a most memorable one.");
public static int calculateAge(int currDate)
int yrs;
yrs = currDate - 1977;
return yrs;
Reply With Quote
Joseph Millar
Posts: n/a
On 20 Jul 2003 16:10:55 -0700, Removed) (Jucy Love) wrote:
> number = oneSite.getSiteNumber();
> oneSite.getSiteNumber(9);

Guess I don't understand this. Here you are getting the
site number before it has ever been set, then you are
making an invalid call, getSiteNumber() does not take an
int as a parameter, it only returns an int as in the
previous call. The above code will not even compile
as written.

Reply With Quote

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Why does "template<typename T> ... function<T(int)>" not match "int(&)(int)" implicitly? Steve Hicks C++ 2 09-28-2009 05:24 PM
Compiling error key(int,int) in ATM2.ATMPanel cannot be applied to (int) powerhouse04 Java 1 12-16-2007 06:03 PM
why is int a[0] not allowed, but int* a = new int[0] is? C++ 9 04-17-2007 09:01 AM
int main(int argc, char *argv[] ) vs int main(int argc, char **argv ) Hal Styli C Programming 14 01-20-2004 10:00 PM
dirty stuff: f(int,int) cast to f(struct{int,int}) Schnoffos C Programming 2 06-27-2003 03:13 AM