SlideShare a Scribd company logo
Java program explanation
• /* The Welcome class implements an application
that simply prints "Hello World..!" to standard
output. */
• class Welcome {
• public static void main(String[] args) {
System.out.println("Hello World..!"); // Display
the string.
• }
• }
Comments
• Comments are ignored by the compiler but are useful
to other programmers. The Java programming
language supports three kinds of comments:
• /* text */ The compiler ignores everything from /* to
*/.
• /** documentation */ This indicates a documentation
comment (doc comment, for short). The compiler
ignores this kind of comment, just like it ignores
comments that use /* and */. The javadoc tool uses
doc comments when preparing automatically
generated documentation.
• // text
• The compiler ignores everything from // to the end of
the line.
Java documentation
• Javadoc (originally cased as JavaDoc) is a
documentation generator created by Sun
Microsystems for the Java language (now
owned by Oracle Corporation) for generating
API documentation in HTML format from Java
source code.
• Some IDEs, such as Netbeans and Eclipse,
automatically generate Javadoc HTML.
Java documentation
• // import statements
• /**
• * @author Firstname Lastname <address @
example.com>
• * @version 1.6 (current version number of
program)
• * @since 2010-03-31 (the version of the package
this class was first added to)
• */
• class Welcome { // class body }
Javadoc tags
Tag & Parameter Usage
@author John Smith Describes an author.
@version version
Provides software version
entry. Max one per Class or
Interface.
@since since-text
Describes when this
functionality has first existed.
@see reference
Provides a link to other
element of documentation.
@param name description Describes a method parameter.
@return description Describes the return value.
class
• The most basic form of a class definition is:
class name { . . . }
• The keyword class begins the class definition
for a class named name
• The code for each class appears between the
opening and closing curly braces
public static void main(String[] args)
{…}
• public means that the method can be seen
outside of this class;
• static means that you don't have to create a
new object;
• void means it doesn't return a value
public static void main(String[] args)
{…}
• The keyword public is an access specifier.
• The keyword static is a kind of modifier.
• The keyword void means that the method main() does not
return any value.
• As we had seen before all the java program will start
execute by calling the main method.
• If we want to pass any information to a method will be
received by the variables declared within the parenthesis is
called parameters.
• In a main() method there is only one parameter ,String
args[] . args[] is a name of the parameter that is an array of
the objects of data type String.
• String store sequences of characters and args will receive
the command line arguments.
public static void main(String[] args)
{…}
• The modifiers public and static can be written in
either order (public static or static public), but
the convention is to use public static as shown
above.
• You can name the argument anything you want,
but most programmers choose "args" or "argv".
• The main method is similar to the main function
in C and C++; it's the entry point for your
application and will subsequently invoke all the
other methods required by your program.
System.out.println("Hello World!");
• Finally, the line:
• System.out.println("Hello World!");
• uses the System class from the core library to
print the "Hello World!" message to standard
output.
• This is included in Java.lang libraray.
static keyword
• The static keyword in Java means that the
variable or function is shared between all
instances of that class as it belongs to the
type, not the actual objects themselves.
• So if you have a variable:
• private static int i = 0;
• and you increment it (i++) in one instance, the
change will be reflected in all instances. i will
now be 1 in all instances.
#_ varible function
Variable
• You can call them almost anything you like, but there are a few
rules:
• Variable names can't start with a number. So first_number is OK,
but not 1st_number. You can have numbers elsewhere in the
variable name, just not at the start.
• Variable names can't be the same as Java keywords. There are
quite a lot of these, like int above.
• You can't have spaces in your variable names. The variable
declaration int first number will get you an error. We've used the
underscore character, but it's common practise to have the first
word start with a lowercase letter and the second or subsequent
words in uppercase: firstNumber, myFirstNumber
• Variable names are case sensitive. So firstNumber and FirstNumber
are different variable names.
Java Keyword
Invalid Identifier
Accepting Input from a User
• One really useful class that handles input from
a user is called the Scanner class.
• The Scanner class can be found in the java.util
library.
• To use the Scanner class, you need to
reference it in your code. This is done with the
keyword import.
• import java.util.Scanner;
Accepting Input from a User
• To create a new Scanner object the code is this:
• Scanner user_input = new Scanner( System.in );
• So instead of setting up an int variable or a String
variable, we're setting up a Scanner variable.
We've called ours user_input.
• After an equals sign, we have the keyword new.
This is used to create new objects from a class.
The object we're creating is from the Scanner
class.
• In between round brackets we have to tell java
that this will be System Input (System.in).
Get the user input
• To get the user input, you can call into action
one of the many methods available to your
new Scanner object. One of these methods is
called next. This gets the next string of text
that a user types on the keyboard:
• String first_name;
first_name = user_input.next( );
Java Option Panes
• Another useful class for accepting user input, and
displaying results, is the JOptionPane class.
• This is located in the javax.swing library.
• The JOptionPane class allows you to have i/o
boxes like this one:
Java Option Panes
• import javax.swing.JOptionPane;
• This tells java that we want to use the
JOptionPane class, located in the javax.swing
library.
What Is a Package?
• A package is a namespace that organizes a set
of related classes and interfaces.
• The Java platform provides an enormous class
library (a set of packages) suitable for use in
your own applications. This library is known as
the "Application Programming Interface", or
"API" for short. Its packages represent the
tasks most commonly associated with general-
purpose programming.
How do I convert a String to an int
data type in Java?
• int i = Integer.parseInt(myString);

More Related Content

PPTX
Java Data Types
PPTX
PCSTt11 overview of java
PPTX
Java Data Types and Variables
PPTX
Java platform
PPTX
Data Types, Variables, and Operators
PPTX
java programming basics - part ii
PDF
ITFT - Java
Java Data Types
PCSTt11 overview of java
Java Data Types and Variables
Java platform
Data Types, Variables, and Operators
java programming basics - part ii
ITFT - Java

What's hot (20)

PPTX
02 data types in java
PPTX
Java basics and java variables
PPT
3 java - variable type
PDF
Introduction java programming
PPTX
Static keyword ppt
PPTX
Java Programming
PPTX
Datatype introduction- JAVA
PDF
Introduction on Data Structures
PDF
Chapter 01 Introduction to Java by Tushar B Kute
PPTX
Quick Scala
PPT
Introduction to objects and inputoutput
PDF
Datatype
PDF
Lecture02 java
PPTX
Pj01 3-java-variable and data types
PPSX
Data types, Variables, Expressions & Arithmetic Operators in java
PPTX
5variables in c#
PPTX
Week 2: Getting Your Hands Dirty – Part 2
PPTX
Constructor in java
PPTX
Week 1: Getting Your Hands Dirty - Part 1
02 data types in java
Java basics and java variables
3 java - variable type
Introduction java programming
Static keyword ppt
Java Programming
Datatype introduction- JAVA
Introduction on Data Structures
Chapter 01 Introduction to Java by Tushar B Kute
Quick Scala
Introduction to objects and inputoutput
Datatype
Lecture02 java
Pj01 3-java-variable and data types
Data types, Variables, Expressions & Arithmetic Operators in java
5variables in c#
Week 2: Getting Your Hands Dirty – Part 2
Constructor in java
Week 1: Getting Your Hands Dirty - Part 1
Ad

Similar to #_ varible function (20)

PPTX
PPTX
Chapter 2 java
PPTX
Multi Threading- in Java WPS Office.pptx
PPTX
Java Module 2 -Vikas.pptx About Java Programming
PPTX
Java Tokens in java program . pptx
PPTX
Java Unit-1.1 chunri kyu shuru kar rh koi si je di of du th n high ch ka dh h...
PDF
Object Oriented Programming with Java Basic Syntax.pdf
PPT
Jacarashed-1746968053-300050282-Java.ppt
DOCX
OOP-Chap2.docx
PPTX
OOP_Abstraction_An Overview of Java.pptx
PPTX
Java programing language unit 1 introduction
PPTX
Module 1.pptx
PPTX
PDF
Introduction to c first week slides
PPTX
chapter 1-overview of java programming.pptx
PPTX
Java For beginners and CSIT and IT students
PPTX
Java introduction
PPTX
PDF
java intro.pptx.pdf
PPTX
Introduction to Kotlin for Android developers
Chapter 2 java
Multi Threading- in Java WPS Office.pptx
Java Module 2 -Vikas.pptx About Java Programming
Java Tokens in java program . pptx
Java Unit-1.1 chunri kyu shuru kar rh koi si je di of du th n high ch ka dh h...
Object Oriented Programming with Java Basic Syntax.pdf
Jacarashed-1746968053-300050282-Java.ppt
OOP-Chap2.docx
OOP_Abstraction_An Overview of Java.pptx
Java programing language unit 1 introduction
Module 1.pptx
Introduction to c first week slides
chapter 1-overview of java programming.pptx
Java For beginners and CSIT and IT students
Java introduction
java intro.pptx.pdf
Introduction to Kotlin for Android developers
Ad

Recently uploaded (20)

PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
Sustainable Sites - Green Building Construction
PPT
Project quality management in manufacturing
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
DOCX
573137875-Attendance-Management-System-original
PDF
PPT on Performance Review to get promotions
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
additive manufacturing of ss316l using mig welding
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
web development for engineering and engineering
PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
UNIT 4 Total Quality Management .pptx
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Sustainable Sites - Green Building Construction
Project quality management in manufacturing
bas. eng. economics group 4 presentation 1.pptx
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
573137875-Attendance-Management-System-original
PPT on Performance Review to get promotions
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
additive manufacturing of ss316l using mig welding
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
web development for engineering and engineering
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
UNIT 4 Total Quality Management .pptx
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems

#_ varible function

  • 1. Java program explanation • /* The Welcome class implements an application that simply prints "Hello World..!" to standard output. */ • class Welcome { • public static void main(String[] args) { System.out.println("Hello World..!"); // Display the string. • } • }
  • 2. Comments • Comments are ignored by the compiler but are useful to other programmers. The Java programming language supports three kinds of comments: • /* text */ The compiler ignores everything from /* to */. • /** documentation */ This indicates a documentation comment (doc comment, for short). The compiler ignores this kind of comment, just like it ignores comments that use /* and */. The javadoc tool uses doc comments when preparing automatically generated documentation. • // text • The compiler ignores everything from // to the end of the line.
  • 3. Java documentation • Javadoc (originally cased as JavaDoc) is a documentation generator created by Sun Microsystems for the Java language (now owned by Oracle Corporation) for generating API documentation in HTML format from Java source code. • Some IDEs, such as Netbeans and Eclipse, automatically generate Javadoc HTML.
  • 4. Java documentation • // import statements • /** • * @author Firstname Lastname <address @ example.com> • * @version 1.6 (current version number of program) • * @since 2010-03-31 (the version of the package this class was first added to) • */ • class Welcome { // class body }
  • 5. Javadoc tags Tag & Parameter Usage @author John Smith Describes an author. @version version Provides software version entry. Max one per Class or Interface. @since since-text Describes when this functionality has first existed. @see reference Provides a link to other element of documentation. @param name description Describes a method parameter. @return description Describes the return value.
  • 6. class • The most basic form of a class definition is: class name { . . . } • The keyword class begins the class definition for a class named name • The code for each class appears between the opening and closing curly braces
  • 7. public static void main(String[] args) {…} • public means that the method can be seen outside of this class; • static means that you don't have to create a new object; • void means it doesn't return a value
  • 8. public static void main(String[] args) {…} • The keyword public is an access specifier. • The keyword static is a kind of modifier. • The keyword void means that the method main() does not return any value. • As we had seen before all the java program will start execute by calling the main method. • If we want to pass any information to a method will be received by the variables declared within the parenthesis is called parameters. • In a main() method there is only one parameter ,String args[] . args[] is a name of the parameter that is an array of the objects of data type String. • String store sequences of characters and args will receive the command line arguments.
  • 9. public static void main(String[] args) {…} • The modifiers public and static can be written in either order (public static or static public), but the convention is to use public static as shown above. • You can name the argument anything you want, but most programmers choose "args" or "argv". • The main method is similar to the main function in C and C++; it's the entry point for your application and will subsequently invoke all the other methods required by your program.
  • 10. System.out.println("Hello World!"); • Finally, the line: • System.out.println("Hello World!"); • uses the System class from the core library to print the "Hello World!" message to standard output. • This is included in Java.lang libraray.
  • 11. static keyword • The static keyword in Java means that the variable or function is shared between all instances of that class as it belongs to the type, not the actual objects themselves. • So if you have a variable: • private static int i = 0; • and you increment it (i++) in one instance, the change will be reflected in all instances. i will now be 1 in all instances.
  • 13. Variable • You can call them almost anything you like, but there are a few rules: • Variable names can't start with a number. So first_number is OK, but not 1st_number. You can have numbers elsewhere in the variable name, just not at the start. • Variable names can't be the same as Java keywords. There are quite a lot of these, like int above. • You can't have spaces in your variable names. The variable declaration int first number will get you an error. We've used the underscore character, but it's common practise to have the first word start with a lowercase letter and the second or subsequent words in uppercase: firstNumber, myFirstNumber • Variable names are case sensitive. So firstNumber and FirstNumber are different variable names.
  • 16. Accepting Input from a User • One really useful class that handles input from a user is called the Scanner class. • The Scanner class can be found in the java.util library. • To use the Scanner class, you need to reference it in your code. This is done with the keyword import. • import java.util.Scanner;
  • 17. Accepting Input from a User • To create a new Scanner object the code is this: • Scanner user_input = new Scanner( System.in ); • So instead of setting up an int variable or a String variable, we're setting up a Scanner variable. We've called ours user_input. • After an equals sign, we have the keyword new. This is used to create new objects from a class. The object we're creating is from the Scanner class. • In between round brackets we have to tell java that this will be System Input (System.in).
  • 18. Get the user input • To get the user input, you can call into action one of the many methods available to your new Scanner object. One of these methods is called next. This gets the next string of text that a user types on the keyboard: • String first_name; first_name = user_input.next( );
  • 19. Java Option Panes • Another useful class for accepting user input, and displaying results, is the JOptionPane class. • This is located in the javax.swing library. • The JOptionPane class allows you to have i/o boxes like this one:
  • 20. Java Option Panes • import javax.swing.JOptionPane; • This tells java that we want to use the JOptionPane class, located in the javax.swing library.
  • 21. What Is a Package? • A package is a namespace that organizes a set of related classes and interfaces. • The Java platform provides an enormous class library (a set of packages) suitable for use in your own applications. This library is known as the "Application Programming Interface", or "API" for short. Its packages represent the tasks most commonly associated with general- purpose programming.
  • 22. How do I convert a String to an int data type in Java? • int i = Integer.parseInt(myString);