• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

var-args

 
gaurav gupta sitm
Ranch Hand
Posts: 47
Java Redhat Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
go(int... z[]) //illegal
go(int[]... z) //legal

why ?
 
Henry Wong
author
Marshal
Pie
Posts: 20881
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
gaurav gupta sitm wrote:go(int... z[]) //illegal
go(int[]... z) //legal

why ?


Interesting. In the Java Language Specification, both seems to be valid grammar. However, the specification only give details for the simpler identifier -- it doesn't defines what to do if the VariableDeclaratorID has array brackets specified (ie. more than a simpler identifier). Or at least, I could not find where the behavior is defined.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic