|
| 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 |
|
|
|
| 27 Nov 2013 12:55 PM |
| Now that I think about it, I should take this to another forum..? |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 27 Nov 2013 12:57 PM |
| Oh. Still kinda new to Java though.. What do you suggest? |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 28 Nov 2013 03:00 PM |
| Thanks for helping me. Fixed the issues. Thanks. |
|
|
| Report Abuse |
|
|