How to write a method that reads particular content in an array lists and count the number of array's content
I am a new learner and I should create a method that will make this program work with no problems at all so I can get the final result that should look like this: 3 is 3 Mark is Mark Richard is Richard Here is the code (PLEASE read the comments I wrote in the code) public class Main { /*I wrote the following method (Student) but I keep get some issues: Please help I spend many days and I can't figure it out and I am runnung out of time as I should understand the problem or at least the correction that I can read and figure out what I was doing wrong.*/ // My written code starts here public static String Student(String[] sx){ int counter = 0; for (int i = 0; i < sx.length; i ++){ if (sx[i] != null) counter ++; } return counter; sx = new String[counter]; } // My written code ENDS here // From this point I should preserve the code without any changes static Student studentA; static Student studentB; static Student studentC; public static void main(String[] args) { studentA = new Student("Mark", "John", "Jimmy"); studentB = new Student("Will", "George", "Androw"); studentC = new Student("Frank", "Sam"); int totalStudents = Student.getTotalStudents(); System.out.println(totalStudents + " is 3"); System.out.println(studentA.getFirstName() + " is Mark"); studentA.setFirstName("Richard"); System.out.println(studentA.getFirstName() + " is Richard"); } }