Timeline for Java: How to pass the array data to a method?
Current License: CC BY-SA 4.0
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Mar 6, 2021 at 2:11 | comment | added | Joey | this answer also worked on a static method, thank you. | |
| Mar 5, 2021 at 16:19 | comment | added | Benjamin M | I'd say it's personal preference and also depends on the use case. It really doesn't make a huge difference if the method is only called in one place. | |
| Mar 5, 2021 at 16:07 | comment | added | m0skit0 |
I think your earlier idea is much better: create a Student#studentInfo() and call it from the loop. Of course a better name would be printStudentInfo().
|
|
| Mar 5, 2021 at 15:34 | comment | added | Benjamin M |
Ah, sorry, had a typo. I should have been simply studentInfo(s) without s1
|
|
| Mar 5, 2021 at 15:33 | history | edited | Benjamin M | CC BY-SA 4.0 |
deleted 3 characters in body
|
| Mar 5, 2021 at 12:47 | comment | added | Joey |
I tried s1.studentInfo(s); earlier, but I only got an error that says Cannot invoke studentInfo(Student) on the array Student[] and IntelliSense is saying that it has to be s1.length.
|
|
| Mar 5, 2021 at 11:45 | history | edited | Benjamin M | CC BY-SA 4.0 |
added 7 characters in body
|
| Mar 5, 2021 at 11:27 | history | answered | Benjamin M | CC BY-SA 4.0 |