i need your help for my project. I'm writing an program which show students informations that users fills previously. this is about how much did i learn the methods. I already wrote a program with out methods. But when i write same things with method i encountered with pass by reference... i am filling the 0. index but when i fill the 1. index, 0. index became a null. I try everything but i cannot solve this problem i think thats about my returns... here is the code can you help me with basically way coz as you can see my Java language level is beginner:) ;
//=========================================================== Methods
public static void record(String x, int y)
String[] stringArray = new String[100];
stringArray[y] = x;
return stringArray;
}
public static double[] record(double x, int y){
double[] doubleArray = new double[100];
doubleArray[y] = x;
return doubleArray;
}
and my option ;
case 1: {
System.out.println("** Recording a new student");
System.out.println("*** Please use lower case");
in.nextLine(); // for solve skipping
System.out.print("Enter Student Name and Surname: ");
String namex = in.nextLine();
name=record(namex,accountNumber);
System.out.print("Enter Student Gender(m/f): ");
String genderx = in.nextLine();
gender=record(genderx,accountNumber);
System.out.print("Enter Student Number: ");
String studentNox = in.nextLine();
studentNo=record(studentNox,accountNumber);
System.out.print("Enter Student GPA: "); // i dont use method here for testing
gpa[accountNumber] = in.nextDouble();
accountNumber++;
System.out.println("New Student Recorded. There are ["+accountNumber+"] students in system.");
System.out.println("");
}break;