Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
18 views

Example: Naming Conversion of Java

The document discusses Java naming conventions for packages, classes, interfaces, constants, variables, and methods. It recommends following standard Java naming conventions to make code more readable for programmers. Specifically, it notes that package names should be in lowercase, class and interface names should have the first letter of each word capitalized, constants should be in uppercase with underscores between words, and variables, methods, and object references should have the first word lowercase and subsequent words capitalized. It also introduces the concept of camel case naming in Java.

Uploaded by

krishna
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Example: Naming Conversion of Java

The document discusses Java naming conventions for packages, classes, interfaces, constants, variables, and methods. It recommends following standard Java naming conventions to make code more readable for programmers. Specifically, it notes that package names should be in lowercase, class and interface names should have the first letter of each word capitalized, constants should be in uppercase with underscores between words, and variables, methods, and object references should have the first word lowercase and subsequent words capitalized. It also introduces the concept of camel case naming in Java.

Uploaded by

krishna
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Naming Conversion of Java

Sun micro system was given following conversions by declaring class, variable, method
etc. So that it is highly recommended to follow this conversion while writing real time
code.
Why Using naming Conversion
Different Java programmers can have different styles and approaches to write program.
By using standard Java naming conventions they make their code easier to read for
themselves and for other programmers. Readability of Java code is important because it
means less time is spent trying to figure out what the code does, and leaving more time
to fix or modify it.
1. Every package name should exist a lower case latter.
Example
package student; // creating package

import java.lang; // import package


2. First letter of every word of class name or interface name should exists in upper case.
Example
class StudentDetails
{
.....
.....
}
interface FacultyDetail
{
.....
.....
}
3. Every constant value should exists in upper case latter. It is containing more than one
word than it should be separated with underscore (-).
Example
class Student
{
final String COLLEGE_NAME="abcd";
....
....
}
Note: if any variable is preceded by final keyword is known as constant value.
Example
class Student
{
Final String Student_name="abcd";
}
While declaring variable name, method, object reference the first letter of first word
should be exits in lower case but from the second words onward the first letter should
exists in upper case.
Example
class Student
{
String StudentName="xyz";
void instantStudentDetails();
{
....
....
}
Student final
CamelCase in java naming conventions

Java follows camelcase syntax for naming the class, interface, method and variable.
According to CamelCase if name is combined with two words, second word will start with
uppercase letter always. General Example studentName, customerAccount. In term of
java programming e.g. actionPerformed(), firstName, ActionEvent, ActionListener etc.

You might also like