• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String int

 
patrick van merchtn
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
very small question.

In my HF book on page 79. Is there a convention to name primitives variables starting with a capital or not. Or does it make no sense ?

//type String starts with a capital.
// type int all lowercase.
 
Chris Beckey
Ranch Hand
Posts: 116
Eclipse IDE Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The convention is for class names to start with a capital letter, primitive types do not. In your example, "String" is the simple class name for "java.lang.String" whereas "int" is a primitive type (i.e. not a class name). If you were to use the "java.lang.Integer" class, which is different from the primitive type "int" then you would (have to) capitalize the first char.
In some sense autoboxing in Java 1.5 has made this more confusing because it looks more like "java.lang.Integer" and "int" are synonomous when they are definately not.
Variable naming convention is a different subject. See the java coding conventions at http://java.sun.com/docs/codeconv/.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic