SlideShare a Scribd company logo
 The javadoc program generates HTML API
documentation from the “javadoc” style comments in
your code.
/* This kind comment can span multiple lines */
// This kind is of to the end of the line
/* This kind of comment is a special
* ‘javadoc’ style comment
*/
 The class is the fundamental concept in JAVA (and other
OOPLs)
 A class describes some data object(s), and the
operations (or methods) that can be applied to those
objects
 Every object and method in Java belongs to a class
 Classes have data (fields) and code (methods) and
classes (member classes or inner classes)
 Static methods and fields belong to the class itself
 Others belong to instances
class Person { Variable
String name;
int age; Method
void birthday ( )
{
age++;
System.out.println (name +
' is now ' + age);
}
}
{ int x = 12;
/* only x available */
{ int q = 96;
/* both x and q available */
}
/* only x available */
/* q “out of scope” */
}
{ int x = 12;
{ int x = 96; /* illegal */
}
}
This is ok in C/C++ but not in Java.
 Java objects don’t have the same lifetimes as
primitives.
 When you create a Java object using new, it
hangs around past the end of the scope.
 Here, the scope of name s is delimited by the {}s
but the String object hangs around until GC’d
{
String s = new String("a string");
} /* end of scope */
 Java methods and variables can be declared static
 These exist independent of any object
 This means that a Class’s
◦ static methods can be called even if no objects of that
class have been created and
◦ static data is “shared” by all instances (i.e., one rvalue
per class instead of one per instance
class StaticTest {static int i = 47;}
StaticTest st1 = new StaticTest();
StaticTest st2 = new StaticTest();
// st1.i == st2.I == 47
StaticTest.i++; // or st1.I++ or
st2.I++
// st1.i == st2.I == 48
public class Circle {public class Circle {
// A class field// A class field
public static final double PI= 3.14159; // A usefulpublic static final double PI= 3.14159; // A useful
constantconstant
// A class method: just compute a value based on the// A class method: just compute a value based on the
argumentsarguments
public static double radiansToDegrees(double rads) {public static double radiansToDegrees(double rads) {
return rads * 180 / PI;return rads * 180 / PI;
}}
// An instance field// An instance field
public double r; // The radius of thepublic double r; // The radius of the
circlecircle
// Two methods which operate on the instance fields of// Two methods which operate on the instance fields of
an objectan object
public double area() { // Compute the area ofpublic double area() { // Compute the area of
the circlethe circle
return PI * r * r;return PI * r * r;
}}
public double circumference() { // Compute thepublic double circumference() { // Compute the
circumference of the circlecircumference of the circle
return 2 * PI * r;return 2 * PI * r;
}}
}}
 Subscripts always start at 0 as in C
 Subscript checking is done automatically
 Certain operations are defined on arrays of
objects, as for other classes
◦ e.g. myArray.length == 5
 Person mary = new Person ( );
 int myArray[ ] = new int[5];
 int myArray[ ] = {1, 4, 9, 16, 25};
 String languages [ ] = {"Prolog", "Java"};
 Since arrays are objects they are allocated dynamically
 Arrays, like all objects, are subject to garbage collection
when no more references remain
◦ so fewer memory leaks
◦ Java doesn’t have pointers!
Example
Programs
 C:UMBC331java>type echo.java
 // This is the Echo example from the Sun tutorial
 class echo {
 public static void main(String args[]) {
 for (int i=0; i < args.length; i++) {
 System.out.println( args[i] );
 }
 }
 }
 C:UMBC331java>javac echo.java
 C:UMBC331java>java echo this is pretty silly
 this
 is
 pretty
 silly
 C:UMBC331java> NSIT ,Jetalpur
/* This program computes the factorial of a number
*/
public class Factorial { // Define a class
public static void main(String[] args) { // The program starts
here
int input = Integer.parseInt(args[0]); // Get the user's
input
double result = factorial(input); // Compute the
factorial
System.out.println(result); // Print out the
result
} // The main() method
ends here
public static double factorial(int x) { // This method
computes x!
if (x < 0) // Check for bad
input
return 0.0; // if bad, return 0
double fact = 1.0; // Begin with an
initial value
while(x > 1) { // Loop until x
equals
fact = fact * x; // multiply by x
each time NSIT ,Jetalpur
 Classes should define one or more methods to create
or construct instances of the class
 Their name is the same as the class name
◦ note deviation from convention that methods begin with lower
case
 Constructors are differentiated by the number and
types of their arguments
◦ An example of overloading
 If you don’t define a constructor, a default one will be
created.
 Constructors automatically invoke the zero argument
constructor of their superclass when they begin (note
that this yields a recursive process!)
NSIT ,Jetalpur
 Java methods are like C/C++ functions.
General case:
returnType methodName ( arg1, arg2, … argN)
{
methodBody
}
The return keyword exits a method optionally with a value
int storage(String s) {return s.length() * 2;}
boolean flag() { return true; }
float naturalLogBase() { return 2.718f; }
void nothing() { return; }
void nothing2() {}

More Related Content

What's hot

What's hot (20)

Java basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini indiaJava basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini india
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Core Java
Core JavaCore Java
Core Java
 
Built in classes in java
Built in classes in javaBuilt in classes in java
Built in classes in java
 
Java Tutorial
Java Tutorial Java Tutorial
Java Tutorial
 
Java basics variables
 Java basics   variables Java basics   variables
Java basics variables
 
Java Fundamentals
Java FundamentalsJava Fundamentals
Java Fundamentals
 
Java Tut1
Java Tut1Java Tut1
Java Tut1
 
Kotlin
KotlinKotlin
Kotlin
 
Core java concepts
Core    java  conceptsCore    java  concepts
Core java concepts
 
Java Tutorial | My Heart
Java Tutorial | My HeartJava Tutorial | My Heart
Java Tutorial | My Heart
 
Java tut1 Coderdojo Cahersiveen
Java tut1 Coderdojo CahersiveenJava tut1 Coderdojo Cahersiveen
Java tut1 Coderdojo Cahersiveen
 
Presentation to java
Presentation  to  javaPresentation  to  java
Presentation to java
 
Java Generics
Java GenericsJava Generics
Java Generics
 
Generic Programming in java
Generic Programming in javaGeneric Programming in java
Generic Programming in java
 
Unit I Advanced Java Programming Course
Unit I   Advanced Java Programming CourseUnit I   Advanced Java Programming Course
Unit I Advanced Java Programming Course
 
Core java
Core javaCore java
Core java
 
Generics in java
Generics in javaGenerics in java
Generics in java
 
Java Generics - by Example
Java Generics - by ExampleJava Generics - by Example
Java Generics - by Example
 
Synapseindia reviews.odp.
Synapseindia reviews.odp.Synapseindia reviews.odp.
Synapseindia reviews.odp.
 

Viewers also liked

Webservices testing using SoapUI
Webservices testing using SoapUIWebservices testing using SoapUI
Webservices testing using SoapUITesting World
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java ProgrammingRavi Kant Sahu
 
Web Services Automated Testing via SoapUI Tool
Web Services Automated Testing via SoapUI ToolWeb Services Automated Testing via SoapUI Tool
Web Services Automated Testing via SoapUI ToolSperasoft
 
Testing web services
Testing web servicesTesting web services
Testing web servicesTaras Lytvyn
 

Viewers also liked (7)

Webservices testing using SoapUI
Webservices testing using SoapUIWebservices testing using SoapUI
Webservices testing using SoapUI
 
Java basic
Java basicJava basic
Java basic
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
Core java slides
Core java slidesCore java slides
Core java slides
 
Web Services Automated Testing via SoapUI Tool
Web Services Automated Testing via SoapUI ToolWeb Services Automated Testing via SoapUI Tool
Web Services Automated Testing via SoapUI Tool
 
Testing web services
Testing web servicesTesting web services
Testing web services
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
 

Similar to Core java concepts

Best Core Java Training In Bangalore
Best Core Java Training In BangaloreBest Core Java Training In Bangalore
Best Core Java Training In Bangalorerajkamaltibacademy
 
Java basic tutorial
Java basic tutorialJava basic tutorial
Java basic tutorialBui Kiet
 
Java Basics
Java BasicsJava Basics
Java BasicsF K
 
Corejava Training in Bangalore Tutorial
Corejava Training in Bangalore TutorialCorejava Training in Bangalore Tutorial
Corejava Training in Bangalore Tutorialrajkamaltibacademy
 
Core Java Concepts
Core Java ConceptsCore Java Concepts
Core Java Conceptsmdfkhan625
 
Java assignment help
Java assignment helpJava assignment help
Java assignment helpJacob William
 
Core java concepts
Core    java  conceptsCore    java  concepts
Core java conceptsChikugehlot
 
Defining classes-and-objects-1.0
Defining classes-and-objects-1.0Defining classes-and-objects-1.0
Defining classes-and-objects-1.0BG Java EE Course
 
Unit 1 Part - 3 constructor Overloading Static.ppt
Unit 1 Part - 3  constructor Overloading Static.pptUnit 1 Part - 3  constructor Overloading Static.ppt
Unit 1 Part - 3 constructor Overloading Static.pptDeepVala5
 
object oriented programming using java, second sem BCA,UoM
object oriented programming using java, second sem BCA,UoMobject oriented programming using java, second sem BCA,UoM
object oriented programming using java, second sem BCA,UoMambikavenkatesh2
 
Week9 Intro to classes and objects in Java
Week9 Intro to classes and objects in JavaWeek9 Intro to classes and objects in Java
Week9 Intro to classes and objects in Javakjkleindorfer
 
Java for the Impatient, Java Constructors, Scope, Wrappers, Inheritance, and ...
Java for the Impatient, Java Constructors, Scope, Wrappers, Inheritance, and ...Java for the Impatient, Java Constructors, Scope, Wrappers, Inheritance, and ...
Java for the Impatient, Java Constructors, Scope, Wrappers, Inheritance, and ...argsstring
 

Similar to Core java concepts (20)

Java Concepts
Java ConceptsJava Concepts
Java Concepts
 
Best Core Java Training In Bangalore
Best Core Java Training In BangaloreBest Core Java Training In Bangalore
Best Core Java Training In Bangalore
 
Java02
Java02Java02
Java02
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Java basic tutorial
Java basic tutorialJava basic tutorial
Java basic tutorial
 
Java
JavaJava
Java
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Java
JavaJava
Java
 
Corejava Training in Bangalore Tutorial
Corejava Training in Bangalore TutorialCorejava Training in Bangalore Tutorial
Corejava Training in Bangalore Tutorial
 
Core Java Concepts
Core Java ConceptsCore Java Concepts
Core Java Concepts
 
Java assignment help
Java assignment helpJava assignment help
Java assignment help
 
Core java concepts
Core    java  conceptsCore    java  concepts
Core java concepts
 
Java Programming - 04 object oriented in java
Java Programming - 04 object oriented in javaJava Programming - 04 object oriented in java
Java Programming - 04 object oriented in java
 
Defining classes-and-objects-1.0
Defining classes-and-objects-1.0Defining classes-and-objects-1.0
Defining classes-and-objects-1.0
 
OOPs & Inheritance Notes
OOPs & Inheritance NotesOOPs & Inheritance Notes
OOPs & Inheritance Notes
 
Unit 1 Part - 3 constructor Overloading Static.ppt
Unit 1 Part - 3  constructor Overloading Static.pptUnit 1 Part - 3  constructor Overloading Static.ppt
Unit 1 Part - 3 constructor Overloading Static.ppt
 
object oriented programming using java, second sem BCA,UoM
object oriented programming using java, second sem BCA,UoMobject oriented programming using java, second sem BCA,UoM
object oriented programming using java, second sem BCA,UoM
 
Week9 Intro to classes and objects in Java
Week9 Intro to classes and objects in JavaWeek9 Intro to classes and objects in Java
Week9 Intro to classes and objects in Java
 
Java for the Impatient, Java Constructors, Scope, Wrappers, Inheritance, and ...
Java for the Impatient, Java Constructors, Scope, Wrappers, Inheritance, and ...Java for the Impatient, Java Constructors, Scope, Wrappers, Inheritance, and ...
Java for the Impatient, Java Constructors, Scope, Wrappers, Inheritance, and ...
 
Sonu wiziq
Sonu wiziqSonu wiziq
Sonu wiziq
 

More from javeed_mhd

For each component in mule
For each component in muleFor each component in mule
For each component in mulejaveed_mhd
 
Filter expression in mule
Filter expression in muleFilter expression in mule
Filter expression in mulejaveed_mhd
 
File component in mule
File component in muleFile component in mule
File component in mulejaveed_mhd
 
Database component in mule
Database component in muleDatabase component in mule
Database component in mulejaveed_mhd
 
Choice component in mule
Choice component in muleChoice component in mule
Choice component in mulejaveed_mhd
 
Vm component in mule
Vm component in muleVm component in mule
Vm component in mulejaveed_mhd
 
Until successful component in mule
Until successful component in muleUntil successful component in mule
Until successful component in mulejaveed_mhd
 
Quartz component in mule
Quartz component in muleQuartz component in mule
Quartz component in mulejaveed_mhd
 
Mule management console installation
Mule management console installation Mule management console installation
Mule management console installation javeed_mhd
 
Mule esb made system integration easy
Mule esb made system integration easy Mule esb made system integration easy
Mule esb made system integration easy javeed_mhd
 
Message properties component in mule
Message properties component in muleMessage properties component in mule
Message properties component in mulejaveed_mhd
 
Junit in mule demo
Junit in mule demo Junit in mule demo
Junit in mule demo javeed_mhd
 
How to install sonarqube plugin in anypoint
How to install sonarqube plugin in anypoint How to install sonarqube plugin in anypoint
How to install sonarqube plugin in anypoint javeed_mhd
 
How to commit a project in svn using svn plugin in anypointstudio
How to commit a project in svn using svn plugin in anypointstudioHow to commit a project in svn using svn plugin in anypointstudio
How to commit a project in svn using svn plugin in anypointstudiojaveed_mhd
 
Mapping and listing with mule
Mapping and listing with mule Mapping and listing with mule
Mapping and listing with mule javeed_mhd
 
Mule any point exchange
Mule any point exchangeMule any point exchange
Mule any point exchangejaveed_mhd
 
Mule esb api layer
Mule esb api layer Mule esb api layer
Mule esb api layer javeed_mhd
 
Mule Maven Plugin
Mule Maven PluginMule Maven Plugin
Mule Maven Pluginjaveed_mhd
 
Mule esb stripe
Mule esb stripeMule esb stripe
Mule esb stripejaveed_mhd
 
Mule with stored procedure
Mule with stored procedureMule with stored procedure
Mule with stored procedurejaveed_mhd
 

More from javeed_mhd (20)

For each component in mule
For each component in muleFor each component in mule
For each component in mule
 
Filter expression in mule
Filter expression in muleFilter expression in mule
Filter expression in mule
 
File component in mule
File component in muleFile component in mule
File component in mule
 
Database component in mule
Database component in muleDatabase component in mule
Database component in mule
 
Choice component in mule
Choice component in muleChoice component in mule
Choice component in mule
 
Vm component in mule
Vm component in muleVm component in mule
Vm component in mule
 
Until successful component in mule
Until successful component in muleUntil successful component in mule
Until successful component in mule
 
Quartz component in mule
Quartz component in muleQuartz component in mule
Quartz component in mule
 
Mule management console installation
Mule management console installation Mule management console installation
Mule management console installation
 
Mule esb made system integration easy
Mule esb made system integration easy Mule esb made system integration easy
Mule esb made system integration easy
 
Message properties component in mule
Message properties component in muleMessage properties component in mule
Message properties component in mule
 
Junit in mule demo
Junit in mule demo Junit in mule demo
Junit in mule demo
 
How to install sonarqube plugin in anypoint
How to install sonarqube plugin in anypoint How to install sonarqube plugin in anypoint
How to install sonarqube plugin in anypoint
 
How to commit a project in svn using svn plugin in anypointstudio
How to commit a project in svn using svn plugin in anypointstudioHow to commit a project in svn using svn plugin in anypointstudio
How to commit a project in svn using svn plugin in anypointstudio
 
Mapping and listing with mule
Mapping and listing with mule Mapping and listing with mule
Mapping and listing with mule
 
Mule any point exchange
Mule any point exchangeMule any point exchange
Mule any point exchange
 
Mule esb api layer
Mule esb api layer Mule esb api layer
Mule esb api layer
 
Mule Maven Plugin
Mule Maven PluginMule Maven Plugin
Mule Maven Plugin
 
Mule esb stripe
Mule esb stripeMule esb stripe
Mule esb stripe
 
Mule with stored procedure
Mule with stored procedureMule with stored procedure
Mule with stored procedure
 

Recently uploaded

Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...Product School
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsExpeed Software
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka DoktorováCzechDreamin
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIES VE
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Product School
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupCatarinaPereira64715
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxAbida Shariff
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeCzechDreamin
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityScyllaDB
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...Elena Simperl
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀DianaGray10
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...Product School
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...Product School
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyJohn Staveley
 

Recently uploaded (20)

Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT Professionals
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 

Core java concepts

  • 1.
  • 2.  The javadoc program generates HTML API documentation from the “javadoc” style comments in your code. /* This kind comment can span multiple lines */ // This kind is of to the end of the line /* This kind of comment is a special * ‘javadoc’ style comment */
  • 3.  The class is the fundamental concept in JAVA (and other OOPLs)  A class describes some data object(s), and the operations (or methods) that can be applied to those objects  Every object and method in Java belongs to a class  Classes have data (fields) and code (methods) and classes (member classes or inner classes)  Static methods and fields belong to the class itself  Others belong to instances
  • 4. class Person { Variable String name; int age; Method void birthday ( ) { age++; System.out.println (name + ' is now ' + age); } }
  • 5. { int x = 12; /* only x available */ { int q = 96; /* both x and q available */ } /* only x available */ /* q “out of scope” */ } { int x = 12; { int x = 96; /* illegal */ } } This is ok in C/C++ but not in Java.
  • 6.  Java objects don’t have the same lifetimes as primitives.  When you create a Java object using new, it hangs around past the end of the scope.  Here, the scope of name s is delimited by the {}s but the String object hangs around until GC’d { String s = new String("a string"); } /* end of scope */
  • 7.  Java methods and variables can be declared static  These exist independent of any object  This means that a Class’s ◦ static methods can be called even if no objects of that class have been created and ◦ static data is “shared” by all instances (i.e., one rvalue per class instead of one per instance class StaticTest {static int i = 47;} StaticTest st1 = new StaticTest(); StaticTest st2 = new StaticTest(); // st1.i == st2.I == 47 StaticTest.i++; // or st1.I++ or st2.I++ // st1.i == st2.I == 48
  • 8. public class Circle {public class Circle { // A class field// A class field public static final double PI= 3.14159; // A usefulpublic static final double PI= 3.14159; // A useful constantconstant // A class method: just compute a value based on the// A class method: just compute a value based on the argumentsarguments public static double radiansToDegrees(double rads) {public static double radiansToDegrees(double rads) { return rads * 180 / PI;return rads * 180 / PI; }} // An instance field// An instance field public double r; // The radius of thepublic double r; // The radius of the circlecircle // Two methods which operate on the instance fields of// Two methods which operate on the instance fields of an objectan object public double area() { // Compute the area ofpublic double area() { // Compute the area of the circlethe circle return PI * r * r;return PI * r * r; }} public double circumference() { // Compute thepublic double circumference() { // Compute the circumference of the circlecircumference of the circle return 2 * PI * r;return 2 * PI * r; }} }}
  • 9.  Subscripts always start at 0 as in C  Subscript checking is done automatically  Certain operations are defined on arrays of objects, as for other classes ◦ e.g. myArray.length == 5
  • 10.  Person mary = new Person ( );  int myArray[ ] = new int[5];  int myArray[ ] = {1, 4, 9, 16, 25};  String languages [ ] = {"Prolog", "Java"};  Since arrays are objects they are allocated dynamically  Arrays, like all objects, are subject to garbage collection when no more references remain ◦ so fewer memory leaks ◦ Java doesn’t have pointers!
  • 12.  C:UMBC331java>type echo.java  // This is the Echo example from the Sun tutorial  class echo {  public static void main(String args[]) {  for (int i=0; i < args.length; i++) {  System.out.println( args[i] );  }  }  }  C:UMBC331java>javac echo.java  C:UMBC331java>java echo this is pretty silly  this  is  pretty  silly  C:UMBC331java> NSIT ,Jetalpur
  • 13. /* This program computes the factorial of a number */ public class Factorial { // Define a class public static void main(String[] args) { // The program starts here int input = Integer.parseInt(args[0]); // Get the user's input double result = factorial(input); // Compute the factorial System.out.println(result); // Print out the result } // The main() method ends here public static double factorial(int x) { // This method computes x! if (x < 0) // Check for bad input return 0.0; // if bad, return 0 double fact = 1.0; // Begin with an initial value while(x > 1) { // Loop until x equals fact = fact * x; // multiply by x each time NSIT ,Jetalpur
  • 14.  Classes should define one or more methods to create or construct instances of the class  Their name is the same as the class name ◦ note deviation from convention that methods begin with lower case  Constructors are differentiated by the number and types of their arguments ◦ An example of overloading  If you don’t define a constructor, a default one will be created.  Constructors automatically invoke the zero argument constructor of their superclass when they begin (note that this yields a recursive process!) NSIT ,Jetalpur
  • 15.  Java methods are like C/C++ functions. General case: returnType methodName ( arg1, arg2, … argN) { methodBody } The return keyword exits a method optionally with a value int storage(String s) {return s.length() * 2;} boolean flag() { return true; } float naturalLogBase() { return 2.718f; } void nothing() { return; } void nothing2() {}