Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

url1=url2=url3=null; (?)  RSS feed

 
Edward Spencer Spencer
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

When reviewing code for a combo box, something like code below lay inside a constructor:

URL url1, url2 url3;
url1=url2=url3=null;

I undertstand this as three URL objects being instantiated from the static class URL, but what is the "daisy chain" of object initializations-- url1=url2=url3=null? I have googled for an hour and can’t find an explanation.

Thank you



 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37242
519
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


is the same as



It means take null and assign it to each variable. Not the clearest way of writing code. Most people would prefer:

 
Edward Spencer Spencer
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you!!

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!