generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Can't call a method from a different class

Previous Thread :: Next Thread 
tuxedoman23 is not online. tuxedoman23
Joined: 24 Apr 2009
Total Posts: 4670
27 Nov 2013 12:54 PM
Good afternoon,

I created a method in a class and tried using it in another class after creating a new instance of that class. However, the text editor I am using says that I cannot call that method. I checked the scope declaration of the method and class, but everything looked alright. Is there something I did wrong?


CLASS WITH METHOD:


public class Made{




public double[] angleMeasures = {5.0, 36.7, .25}; //For getAngle method


public double getAngle(double totalMeasure, double[] findAngleMeasure){

double preTotalMeasure = totalMeasure;

for (int i = 0; i < findAngleMeasure.length; i++){

totalMeasure -= findAngleMeasure[i];
System.out.printf("Subtracted %d from the total measurement of the angle with measurement %d.", findAngleMeasure[i], preTotalMeasure);

}

return totalMeasure;

}




}


CLASS WITH THE BASIC OBJECT:


public class testing123 {

public Made test = new Made();
test.getAngle(180, double[] findAngleMeasure);

}
Report Abuse
tuxedoman23 is not online. tuxedoman23
Joined: 24 Apr 2009
Total Posts: 4670
27 Nov 2013 12:55 PM
Now that I think about it, I should take this to another forum..?
Report Abuse
BlueTaslem is not online. BlueTaslem
Joined: 11 May 2008
Total Posts: 11060
27 Nov 2013 12:55 PM
Your class testing123 is not even close to right. It also has a lowercase name which is discouraged in Java.
Report Abuse
tuxedoman23 is not online. tuxedoman23
Joined: 24 Apr 2009
Total Posts: 4670
27 Nov 2013 12:57 PM
Oh. Still kinda new to Java though.. What do you suggest?
Report Abuse
cats247 is not online. cats247
Joined: 04 Jul 2009
Total Posts: 1424
27 Nov 2013 01:02 PM
test.getAngle(180, double[] findAngleMeasure);

Your problem is with the second argument. You can't just define a variable inside of an argument like that, you are supposed to be passing something in. If anything, you should have:

test.getAngle(180, new double[(length)]);

where length = how long the array needs to be. I still wouldn't recommend doing this though. I haven't looked at the code for your method so I don't know if there's a better way of doing this, just a warning.
Report Abuse
cooldude999921 is not online. cooldude999921
Joined: 13 Aug 2011
Total Posts: 3702
27 Nov 2013 03:57 PM
I am only a Visual basic Programmer e.e

Hardly know any of your code displayed. I might as well buy a j++ box and learn from there...
Report Abuse
RaidenJPN is not online. RaidenJPN
Joined: 22 May 2013
Total Posts: 6920
27 Nov 2013 04:36 PM
>J++

Noooooooooo.........

If you're going to use Java,

just get Eclipse.

Besides,

didn't Microsoft discontinue the J++ project and make J#, or whatever it was

called?
Report Abuse
tuxedoman23 is not online. tuxedoman23
Joined: 24 Apr 2009
Total Posts: 4670
28 Nov 2013 03:00 PM
Thanks for helping me. Fixed the issues. Thanks.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image