Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Error with my instance class.
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
copthesaint




PostPosted: Wed Oct 07, 2009 12:00 pm   Post subject: Error with my instance class.

I keep getting the errors int/double cannot be reffered.
Any help? The files are commented, and any other you find will be great to share Smile
Sponsor
Sponsor
Sponsor
sponsor
Vermette




PostPosted: Wed Oct 07, 2009 12:13 pm   Post subject: Re: Error with my instance class.

You're trying to call a method on a primitive due to a scope mismatch.

Java:
public void setInt (String name,int value, int arrayPart){
         int [] lastInt = new int [2];//records the place of the last holder to save speed.
         lastInt [0] = 0;
         lastInt [1] = arrayPart;
         lastInt = value.modifyIntInstance(name,value,lastInt);// changes the value of an int.
      }


Your intent here was to call the InstanceSetup value in your class attribute, but due to scoping rules, you're actually trying to make a method call on the method parameter value, which is a primitive. Object-scope your method call with the this keyword:

Java:
public void setInt (String name,int value, int arrayPart){
         int [] lastInt = new int [2];//records the place of the last holder to save speed.
         lastInt [0] = 0;
         lastInt [1] = arrayPart;
         lastInt = this.value.modifyIntInstance(name,value,lastInt);// changes the value of an int.
      }


But better yet, change the name of the parameter.
copthesaint




PostPosted: Fri Oct 09, 2009 2:06 pm   Post subject: RE:Error with my instance class.

kk thanks Vermette
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: