0% found this document useful (0 votes)
48 views3 pages

Naming Conventions in Java PDF

Uploaded by

Rubina Banu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
48 views3 pages

Naming Conventions in Java PDF

Uploaded by

Rubina Banu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 3
<€ Naming Conventions Name Convention should start with uppercase letter and be class name |a noun e.g. String, Color, Button, System, Thread etc. : should start with uppercase letter and be interface Rama an adjective e.g. Runnable, Remote, ActionListener etc. should start with lowercase letter and be a method ‘| 7 verb e.g. actionPerformed(), main(), print(), name printin() etc. variable should start with lowercase letter e.g. name firstName, orderNumber etc. package | should be in lowercase letter e.g, java, name lang, sql, util etc. constants | should be in uppercase letter. e.g. RED, name YELLOW, MAX_PRIORITY etc. Cases in Java Naming Convention: Using the right letter case is the key to following a naming convention: e Lowercase is where all the letters in a word are written without any capitalization (e.g., while, if, mypackage). e Uppercase is where all the letters in a word are written in capitals. When there are more than two words in the name use underscores to separate them (e.g., MAX_HOURS, FIRST_DAY_OF_WEEK). ¢ CamelCase (also known as Upper CamelCase) is where each new word begins with a capital letter (e.g., CamelCase, CustomerAccount, PlayingCard). e Mixed case (also known as Lower CamelCase) is the same as CamelCase except the first letter of the name is in lowercase (e.g., hasChildren, customerFirstName, customerLastName). Examples: Classes: class MyClass { } Objects/Variables: String myName; MyClass myObject; Scanner scannerObject = new Scanner(Sys tem.in); Methods: void myMethod() { } String myName = scannerObject.nextLine QO; Constant Variables: static final char END_OF_FILE = 'e'; myFrame.setDefaultCloseOperation(JFrame. EXIT_ON_CLOSE) ;

You might also like