Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

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

 
 
Jucy Love
Guest
Posts: n/a
 
      07-20-2003
this is the first file called EventSite3.java
public class EventSite3
{
private int siteNumber;
public int getSiteNumber()
{
return siteNumber;
}
public void setSiteNumber(int n)
{
siteNumber = n;
}
}

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


public void statementOfPhilosophy()
{
age = calculateAge(currentYear);
number = oneSite.getSiteNumber();
oneSite.getSiteNumber(9);
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
Guest
Posts: n/a
 
      07-21-2003
On 20 Jul 2003 16:10:55 -0700, http://www.velocityreviews.com/forums/(E-Mail 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.

--Joe
 
Reply With Quote
 
 
 
Reply

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? haijin.biz@gmail.com 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



Advertisments