• Post Reply Bookmark Topic Watch Topic
  • New Topic

InetAddress initialization...  RSS feed

 
Sagar Patel
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Am willing to initialize an array of InetAddress in the class declaration....

As Expected the following code gives a an unhandled UnknownHostException, however, i cannot surround it with try/catch as its in the class declaration...Where am i goofing up...?!

Can I not by anyway initialize the InetAddress array in the class declaration portion...


 
Rob Spoor
Sheriff
Posts: 21050
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this:
This will even work if Srv is final, if you make sure it also gets initialized when the exception is thrown.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!