Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I've been trying to calculate averages for parameters stored in ArrayList but always seem to receive 0 when calling my numberAverage class after adding new int objects to the ArrayList and I could really do with some help to point me in the right direction.
Thank you.
You did the reverse of what mean actually is. Use this:
double mean = ((double)aggregate / numberAverage.size());
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
When i use the below code it is throwing me error
Hashtable htl = new Hashtable(int 50, float 0.90);
Error: Syntax error on token "int", delete this token
You don't place the types when calling a method.
Just replace with
Hashtable htl=new Hashtable(50, 0.90);
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I am getting wrong output while using java Math functions.
expected output = 4.32
present output= 4.30287105016515
double startHeight= 60.00;
double initaldistance=1000.00;
double speed=120;
startDistance=(initaldistance-1.688*speed);
startAngle = Math.toDegrees(Math.atan(startHeight/startDistance));
System.out.println(startAngle);
Your expected output is incorrect. The arithmetic expressed in the code in the question does indeed have a result near 4.30287.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
This is very weird.
A class I wrote has the following data member:
final static long MAX_FILE_SIZE_BYTES = 50000000000L;
at one point in my code the following block is run
System.out.println("MAXFILESIZEBYTES: " + MAX_FILE_SIZE_BYTES);
and the output is:
MAXFILESIZEBYTES: -1539607552
My question is, why is this long value overflowing? Java is supposed to be machine independent, and longs are supposed to hold 64 bits. What gives?
Cannot reproduce.
50000000000L is 0x0000000BA43B7400.
-1539607552 is FFFFFFFFA43B7400, which is what you would get if you cast the value to int.
Ergo somewhere you are casting it to int. Maybe you have a shadowed variable.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
If I try to get the sin and sin-1 of 0.5 degree, I get virtually the same answer.
sin-1(0.5) should have been 30.
Log.d("XYZ", Math.sin(Math.toRadians(0.5)) +"___"+ Math.asin(Math.toRadians(0.5)));
Result: 0.008726535498373935___0.008726757025787037
Any idea what I am doing wrong?
One of the part of your code i.e. Math.asin(Math.toRadians(0.5)) is wrong....
0.5 is a numerical value you don't need to change it to Radians the correct one is.
Log.d("XYZ", Math.sin(Math.toRadians(0.5)) +"___"+ Math.toDegrees(Math.asin(0.5));
the function "Math.asin(0.5)" give value in radians so you need to convert it to degrees.
and it is not "sin-1 of 0.5 degrees" rather it is" sin-1 of 0.5" ..."degrees" must not come...
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I need your help quickly!
I have this small for loop and it says "Cannot find symbol i" or something, but I did defined it in the loop.
for(short i=0;i<pin.length;i++)
if (pin[i].getName().equals(x))
System.out.println("Όνομα"+"\t"+"Μήκος"+"\t"+"Πλάτος"+"\t"+"Εκτόπισμα"+"\t"+"Έτος Κατασκευής"+"\t"+"Μέγιστη Ταχύτητα"+"\t"+"Όνομα ιδιοκτήτη");
System.out.println("name"+"\t"+pin[i].getLength()+"\t"+pin[i].getWidth()+"\t"+pin[i].getDisplacement()+"\t"+pin[i].getYear()+"\t"+pin[i].getSpeed()+"\t"+pin[i].getOwners_name());
}
you need to add {} to define your scopes
for(short i=0;i<pin.length;i++) {
if (pin[i].getName().equals(x)) {
System.out.println("Όνομα"+"\t"+"Μήκος"+"\t"+"Πλάτος"+"\t"+"Εκτόπισμα"+"\t"+"Έτος Κατασκευής"+"\t"+"Μέγιστη Ταχύτητα"+"\t"+"Όνομα ιδιοκτήτη");
System.out.println("name"+"\t"+pin[i].getLength()+"\t"+pin[i].getWidth()+"\t"+pin[i].getDisplacement()+"\t"+pin[i].getYear()+"\t"+pin[i].getSpeed()+"\t"+pin[i].getOwners_name());
}
}