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.
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

What's hot

02 data types in java
02 data types in java02 data types in java
02 data types in java
রাকিন রাকিন
 
Java basics and java variables
Java basics and java variablesJava basics and java variables
Java basics and java variables
Pushpendra Tyagi
 
3 java - variable type
3  java - variable type3  java - variable type
3 java - variable type
vinay arora
 
Introduction java programming
Introduction java programmingIntroduction java programming
Introduction java programming
Nanthini Kempaiyan
 
Static keyword ppt
Static keyword pptStatic keyword ppt
Static keyword ppt
Vinod Kumar
 
Java Programming
Java ProgrammingJava Programming
Java Programming
Nanthini Kempaiyan
 
Datatype introduction- JAVA
Datatype introduction- JAVADatatype introduction- JAVA
Datatype introduction- JAVA
Hamna_sheikh
 
Introduction on Data Structures
Introduction on Data StructuresIntroduction on Data Structures
Introduction on Data Structures
Nanthini Kempaiyan
 
Chapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteChapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B Kute
Tushar B Kute
 
Quick Scala
Quick ScalaQuick Scala
Quick Scala
Puneet Kumar
 
Introduction to objects and inputoutput
Introduction to objects and inputoutput Introduction to objects and inputoutput
Introduction to objects and inputoutput
Ahmad Idrees
 
Datatype
DatatypeDatatype
Datatype
baran19901990
 
Lecture02 java
Lecture02 javaLecture02 java
Lecture02 java
jawidAhmadRohani
 
C#
C#C#
Pj01 3-java-variable and data types
Pj01 3-java-variable and data typesPj01 3-java-variable and data types
Pj01 3-java-variable and data types
SasidharaRaoMarrapu
 
Data types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in javaData types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in java
Javed Rashid
 
5variables in c#
5variables in c#5variables in c#
5variables in c#
Sireesh K
 
Week 2: Getting Your Hands Dirty – Part 2
Week 2: Getting Your Hands Dirty – Part 2Week 2: Getting Your Hands Dirty – Part 2
Week 2: Getting Your Hands Dirty – Part 2
Jamshid Hashimi
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
Madishetty Prathibha
 
Week 1: Getting Your Hands Dirty - Part 1
Week 1: Getting Your Hands Dirty - Part 1Week 1: Getting Your Hands Dirty - Part 1
Week 1: Getting Your Hands Dirty - Part 1
Jamshid Hashimi
 

What's hot (20)

02 data types in java
02 data types in java02 data types in java
02 data types in java
 
Java basics and java variables
Java basics and java variablesJava basics and java variables
Java basics and java variables
 
3 java - variable type
3  java - variable type3  java - variable type
3 java - variable type
 
Introduction java programming
Introduction java programmingIntroduction java programming
Introduction java programming
 
Static keyword ppt
Static keyword pptStatic keyword ppt
Static keyword ppt
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 
Datatype introduction- JAVA
Datatype introduction- JAVADatatype introduction- JAVA
Datatype introduction- JAVA
 
Introduction on Data Structures
Introduction on Data StructuresIntroduction on Data Structures
Introduction on Data Structures
 
Chapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteChapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B Kute
 
Quick Scala
Quick ScalaQuick Scala
Quick Scala
 
Introduction to objects and inputoutput
Introduction to objects and inputoutput Introduction to objects and inputoutput
Introduction to objects and inputoutput
 
Datatype
DatatypeDatatype
Datatype
 
Lecture02 java
Lecture02 javaLecture02 java
Lecture02 java
 
C#
C#C#
C#
 
Pj01 3-java-variable and data types
Pj01 3-java-variable and data typesPj01 3-java-variable and data types
Pj01 3-java-variable and data types
 
Data types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in javaData types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in java
 
5variables in c#
5variables in c#5variables in c#
5variables in c#
 
Week 2: Getting Your Hands Dirty – Part 2
Week 2: Getting Your Hands Dirty – Part 2Week 2: Getting Your Hands Dirty – Part 2
Week 2: Getting Your Hands Dirty – Part 2
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Week 1: Getting Your Hands Dirty - Part 1
Week 1: Getting Your Hands Dirty - Part 1Week 1: Getting Your Hands Dirty - Part 1
Week 1: Getting Your Hands Dirty - Part 1
 

Similar to #_ varible function

Java
JavaJava
Chapter 2 java
Chapter 2 javaChapter 2 java
Chapter 2 java
Ahmad sohail Kakar
 
OOP-Chap2.docx
OOP-Chap2.docxOOP-Chap2.docx
OOP-Chap2.docx
NaorinHalim
 
Java programing language unit 1 introduction
Java programing language unit 1 introductionJava programing language unit 1 introduction
Java programing language unit 1 introduction
chnrketan
 
Module 1.pptx
Module 1.pptxModule 1.pptx
Module 1.pptx
YakaviBalakrishnan
 
Java
JavaJava
Introduction to c first week slides
Introduction to c first week slidesIntroduction to c first week slides
Introduction to c first week slides
luqman bawany
 
chapter 1-overview of java programming.pptx
chapter 1-overview of java programming.pptxchapter 1-overview of java programming.pptx
chapter 1-overview of java programming.pptx
nafsigenet
 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
Partnered Health
 
Java introduction
Java introductionJava introduction
Java introduction
The icfai university jaipur
 
java.pptx
java.pptxjava.pptx
java intro.pptx.pdf
java intro.pptx.pdfjava intro.pptx.pdf
java intro.pptx.pdf
TekobashiCarlo
 
Introduction to Kotlin for Android developers
Introduction to Kotlin for Android developersIntroduction to Kotlin for Android developers
Introduction to Kotlin for Android developers
Mohamed Wael
 
intro_java (1).pptx
intro_java (1).pptxintro_java (1).pptx
intro_java (1).pptx
SmitNikumbh
 
Java for Mainframers
Java for MainframersJava for Mainframers
Java for Mainframers
Rich Helton
 
Java
Java Java
02 basic java programming and operators
02 basic java programming and operators02 basic java programming and operators
02 basic java programming and operators
Danairat Thanabodithammachari
 
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
AssignmentjsnsnshshusjdnsnshhzudjdndndjdAssignmentjsnsnshshusjdnsnshhzudjdndndjd
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
tusharjain613841
 
Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction
AKR Education
 
Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptx
VijalJain3
 

Similar to #_ varible function (20)

Java
JavaJava
Java
 
Chapter 2 java
Chapter 2 javaChapter 2 java
Chapter 2 java
 
OOP-Chap2.docx
OOP-Chap2.docxOOP-Chap2.docx
OOP-Chap2.docx
 
Java programing language unit 1 introduction
Java programing language unit 1 introductionJava programing language unit 1 introduction
Java programing language unit 1 introduction
 
Module 1.pptx
Module 1.pptxModule 1.pptx
Module 1.pptx
 
Java
JavaJava
Java
 
Introduction to c first week slides
Introduction to c first week slidesIntroduction to c first week slides
Introduction to c first week slides
 
chapter 1-overview of java programming.pptx
chapter 1-overview of java programming.pptxchapter 1-overview of java programming.pptx
chapter 1-overview of java programming.pptx
 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
 
Java introduction
Java introductionJava introduction
Java introduction
 
java.pptx
java.pptxjava.pptx
java.pptx
 
java intro.pptx.pdf
java intro.pptx.pdfjava intro.pptx.pdf
java intro.pptx.pdf
 
Introduction to Kotlin for Android developers
Introduction to Kotlin for Android developersIntroduction to Kotlin for Android developers
Introduction to Kotlin for Android developers
 
intro_java (1).pptx
intro_java (1).pptxintro_java (1).pptx
intro_java (1).pptx
 
Java for Mainframers
Java for MainframersJava for Mainframers
Java for Mainframers
 
Java
Java Java
Java
 
02 basic java programming and operators
02 basic java programming and operators02 basic java programming and operators
02 basic java programming and operators
 
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
AssignmentjsnsnshshusjdnsnshhzudjdndndjdAssignmentjsnsnshshusjdnsnshhzudjdndndjd
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
 
Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction
 
Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptx
 

Recently uploaded

Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
VICTOR MAESTRE RAMIREZ
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Sinan KOZAK
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
Engine Lubrication performance System.pdf
Engine Lubrication performance System.pdfEngine Lubrication performance System.pdf
Engine Lubrication performance System.pdf
mamamaam477
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
abbyasa1014
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
nooriasukmaningtyas
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
NidhalKahouli2
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
KrishnaveniKrishnara1
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
IJNSA Journal
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
sachin chaurasia
 
Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
mahammadsalmanmech
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
bijceesjournal
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
Yasser Mahgoub
 

Recently uploaded (20)

Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
Engine Lubrication performance System.pdf
Engine Lubrication performance System.pdfEngine Lubrication performance System.pdf
Engine Lubrication performance System.pdf
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
 
Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
 

#_ 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.
  • 12.
  • 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);