• Post Reply Bookmark Topic Watch Topic
  • New Topic

Don't understand how to use a named constant.  RSS feed

 
Ryan Bishop
Ranch Hand
Posts: 143
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm new to Java and have been stuck on how to use a final declaration statement once it's made. Below is a class I'm creating with the intention of calling it under a main method. I don't understand if I'm supposed to do anything else, like do some sort of get/set, or if the final static line is all I need. And, I don't know how I call it to the main method once I do. I'm embarrassed to admit I've spent hours on this, can't find the answer in my book, can't find the answer online (maybe I'm using the wrong terms), and would appreciate any advice. Thanks.



 
Ryan Bishop
Ranch Hand
Posts: 143
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nevermind, I figured it out assuming I don't write anything more and in the println just put Shirt.MATERIAL.
 
Paul Clapham
Sheriff
Posts: 22832
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup, that right, that's how you would use that constant.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
Niraj Jha
Ranch Hand
Posts: 63
Java Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Avoid using hard coded constant value, better to externalize in properties file.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Avoid using hard coded constant value, better to externalize in properties file.

Stated in the absolute ("... is is better...") I disagree with this. But a discussion on this would take us off-topic, and not help Gob.
 
Ryan Bishop
Ranch Hand
Posts: 143
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:And welcome to the Ranch


Thanks
 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, "Gob Bluth" is like "CIA Agency", redundant. "Gob" is really "GOB" for George Oscar Bluth, ergo Gob Bluth == George Oscar Bluth Bluth.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!