Java Naming conventions
Java Naming conventions
Java naming convention is a rule to follow as you decide what to name your identifiers such as
class, package, variable, constant, method etc.
All the classes, interfaces, packages, methods and fields of java programming language are given
according to java naming convention.
Name Convention
should start with uppercase letter and be a noun e.g. String, Color, Button, System,
class name
Thread etc.
interface should start with uppercase letter and be an adjective e.g. Runnable, Remote,
name ActionListener etc.
should start with lowercase letter and be a verb e.g. actionPerformed(), main(),
method name
print(), println() etc.
variable name should start with lowercase letter e.g. firstName, orderNumber etc.
package name should be in lowercase letter e.g. java, lang, sql, util etc.
constants
should be in uppercase letter. e.g. RED, YELLOW, MAX_PRIORITY etc.
name
If name is combined with two words, second word will start with uppercase letter always e.g.
actionPerformed(), firstName, ActionEvent, ActionListener etc.
The java command-line argument is an argument i.e. passed at the time of running the java program.
The arguments passed from the console can be received in the java program and it can be used as an
input.
So, it provides a convenient way to check the behavior of the program for the different values. You can
pass N (1,2,3 and so on) numbers of arguments from the command prompt.
Simple example of command-line argument in java
In this example, we are receiving only one argument and printing it. To run this java program, you must
pass at least one argument from the command prompt.
class CommandLineExample{
public static void main(String args[]){
System.out.println("Your first argument is: "+args[0]);
}
}
class A{
public static void main(String args[]){
for(int i=0;i<args.length;i++)
System.out.println(args[i]);
}
}
Output: sonoo
jaiswal
1
3
abc
91-9990449935
0120-4256464
Home
Core Java
Servlet
JSP
EJB
Struts2
Mail
Hibernate
Spring
Android
Design P
Quiz
Projects
Interview Q
Comment
Forum
Training
Basics of Java OOPs Concepts Java String Java Regex Exception Handling Java Inner classes
Java Multithreading
What is Multithreading Life Cycle of a Thread Creating Thread Thread Scheduler Sleeping a thread Start
a thread twice Calling run() method Joining a thread Naming a thread Thread Priority Daemon Thread
Thread Pool Thread Group ShutdownHook Performing multiple task Garbage Collection Runtime class
Multithreading quiz-1 Multithreading quiz-2
Java Synchronization
Synchronization in java synchronized block static synchronization Deadlock in Java Inter-thread Comm
Interrupting Thread Reentrant Monitor
Java I/O Java Networking Java AWT Java Swing Java Applet Java Reflection Java Date Java Conversion
Java Collection Java JDBC Java New Features RMI Internationalization Interview Questions
next>> <<prev
Thread class:
Thread class provide constructors and methods to create and perform operations on a thread.Thread
class extends Object class and implements Runnable interface.
Thread()
Thread(String name)
Thread(Runnable r)
Thread(Runnable r,String name)
Runnable interface:
The Runnable interface should be implemented by any class whose instances are intended to be
executed by a thread. Runnable interface have only one method named run().
Starting a thread:
start() method of Thread class is used to start a newly created thread. It performs following tasks:
Output:thread is running...
Output:thread is running...
If you are not extending the Thread class,your class object would not be treated as a thread object.So
you need to explicitely create Thread class object.We are passing the object of your class that
implements Runnable so that your class run() method may execute.
<<prev next>>
Like/Subscribe us for latest updates or newsletter ↑Top
Tutorials
Interview Questions
» Java Interview
» Servlet Interview
» JSP Interview
» Hibernate Interview
» Spring Interview
» Android Interview
» SQL Interview
» PL/SQL Interview
» Oracle Interview
» MySQL Interview
» SQL Server Interview
» MongoDB Interview
» Cloud Interview
Quizzes
Forum
Projects
» Development
» Training
» SEO
» Consultancy
CONTACT US
Tel. : 0120-4256464
Mob. : +91 9990449935
Email : [email protected]
Address: 2nd Floor, G-13,
(Near 16 Metro Station),
Sec - 3, Noida,
201301, UP, India
» Contact Us
» Privacy Policy
© 2011-2014 Javatpoint.
All Rights Reserved.