0

String[] args, why?

In this code class MyClass { static int sum(int val1, int val2) { return val1 + val2; } public static void main(String[ ] args) { int x = sum(2, 5); System.out.println(x); } } Why is it String[] args but not String args[]?

5th Nov 2019, 5:05 PM
Brendan
Brendan - avatar
3 Réponses
+ 3
Tibor Santa Thanks! Got the answer, but thanks anyway for taking out the time to answer!
5th Nov 2019, 6:04 PM
Brendan
Brendan - avatar
+ 2
Thesmallest Thanks! This cleared a couple of doubts.
5th Nov 2019, 5:45 PM
Brendan
Brendan - avatar
+ 2
Java offers two ways to declare arrays: typename[] variablename typename variablename[] Both are legit, but the usual convention is the first form.
5th Nov 2019, 5:54 PM
Tibor Santa
Tibor Santa - avatar