Im new at android developing. I want to use the returning value of "mean" and than displaying as a string, but I cant reach it from onCreate and I dont know how to do that. Here is the code:
public class DisplayMessageActivity extends Activity {
int[] x = {1, 2, 3, 4, 5, 6 ,7, 8 ,9, 10};
public static double mean(double[] x) {
double sum = 0;
for (int i = 0; i < x.length; i++) {
sum += x[i];
}
return sum / x.length;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display_message);
getActionBar().setDisplayHomeAsUpEnabled(true);
Intent intent = getIntent();
String message = double.toString(mean);
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(message);
setContentView(textView);
}
Thanks for helping me out!