• Post Reply Bookmark Topic Watch Topic
  • New Topic

please explain the loop  RSS feed

 
Dana Horst
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys, I have the code :


Could anyone explain me how the method "toUpperCase" works? there is array of String , but in the loop we use int, it is confusing. Thank you!
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The method toUpperCase in your class Passer gets an array of strings as a parameter. In lines 4 to 6, the method loops over the array.

Note that in line 5, text[i] refers to an element of the array of strings (the i-th element). On each element, toUpperCase is called (Note! This is the method toUpperCase in class String, not to be confused with your own method toUpperCase in class Passer!). The result of that call is put back into the array.

For more details about arrays, see: Arrays in Oracle's Java Tutorials.
 
Dana Horst
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jesper!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!