SlideShare a Scribd company logo
Chapter 2  Using Variables and Constants
Objectives ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Applet Panel with Text Field, Text Area, and a Button
Constructor Methods   Constructor method executes automatically
Variables and Constants   ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
 
Java Data Types   ,[object Object],[object Object],[object Object]
Java Primitive Data Types Unicode character—a code designed for internationalization of applications char code 0 single character chr char -128 to 127 0 small integers byt byte true or false false true or false bln boolean   Possible Values   Default Initial Value Contents Naming Prefix   Data Type
Java Primitive Data Types  Continued -32,768 to 32,767 0 short integer int short -9,223,372.036,854,775,808L to 9,223,372,036,854,775,807L 0 long integer lng long -2,147,483,648 to 2,147,483,647 0 integer data int int 7 digit precision 0.0 single precision floating point number flt float 15 digit precision 0.0   double precision floating point number dbl double
Valid and Invalid Variable Names   Accepted by Java but is a terrible identifier, since the name is not meaningful. valid X No periods allowed. invalid dblBig.Number Only letters, letters, and underscore characters allowed. No special characters. invalid fltBig# Must begin with a letter or underscore. invalid 2Times valid blnIsFinished valid chrLetter valid int_Person_Count No spaces allowed in a name. invalid int Person Count Reason Valid or Invalid Identifier
Declaring Variables   ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Forming Numeric Literals   ,[object Object],[object Object],[object Object]
Declaring Numeric Constants   ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Selected Java Data Type Wrapper Classes   Integer Int Integer floating point numeric Flt Float True or False Bln Boolean character data str String Contents Naming Prefix DataType
Scope and Lifetime of Variables   New copy each time the method is called. Until the method ends. Visible only inside the method where it is declared. Inside a method. Local One copy for each object instantiated from the class. As long as this specific instance of the class exists. Visible in all methods of the class. Inside a class but not within a method. Instance  One copy for the class. As long as any instance of the class exists. Visible in all methods of the class. Inside a class but not within a method.  Keyword  static . Class  Memory allocated Lifetime Scope (Visibility) Location of Declaration Type
The TextField Component—Constructor Formats   TextField() TextField(int maximumNumberCharacters) TextField(String initialValue) TextField(String initialValue, int maximumNumberCharacters)
The TextField Component—Examples   TextField txtName = new TextField(20); TextField txtQuantity = new TextField(5); TextField txtZipCode = new TextField("91789"); TextField txtZipCode = new TextField("91789",9);
The TextArea Component—Constructor Formats   TextArea() TextArea(int numberRows, int maximumNumberCharacters) TextArea(String initialValue) TextArea(String initialValue, int numberRows, int maxNumberCharacters) TextArea(String initialValue, int numberRows, int maxNumberCharacters, int Scroll)
The TextArea Component—Examples   TextArea txaInvoice = new TextArea(20,40); TextArea txaGrades = new TextArea(15,20); TextArea txaGrade = new TextArea("Name  Average",15, 20); TextArea txaGrade = new TextArea("Name  Average", 15, 20,  TextArea.SCROLLBARS_BOTH)
Selected Methods of the TextField and TextArea Components   Returns only the text that is selected in the text component. getSelectedText() Selects (highlights) the contents of the text component. selectAll() Adds text to the end of the contents, only available with TextArea. append() Assigns the value to the text component. setText(String  value ) Returns the contents of the text component. getText() Purpose Method
The getText Method—General Format componentName .getText()
The getText Method —Example   strName = txtName.getText();
The setText Method—General Format   componentName.setText(string to be displayed)
The setText Method—Examples   lblMessage.setText("Hello World"); txtGreeting.setText(strName); txtAnswer.setText("Hello " + txtName.getText()); txtName.setText(""); //Clear the text field
Concatenation   “ +” means concatenation of two items
Including Control Characters   ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The append Method—General Format   componentName .append( string );
The Append Method—Examples   txaInvoice.append("Sold To:  " + strName +""); txaInvoice.append("Address: " + strStreet + ""); txaInvoice.append(" City:  " + strCity);
Use Unnamed Labels for Prompts Prompts
Prompts for Text Components   ,[object Object],[object Object],[object Object]
Positioning the Cursor   ,[object Object],[object Object],[object Object]
System Dates   ,[object Object],[object Object]
Partial List of Calendar Integer Constants Minute of hour MINUTE Hour (12 hour time) HOUR BC or AD ERA Starts with 0 for Sunday DAY_OF_WEEK Julian date DAY_OF_YEAR Day starting with 1 DAY_OF_MONTH Month starting with 0 MONTH 4 digit year YEAR Returns Constant
The Button Component—Constructor Formats   Button() Button(String  label );
The Button Component—Examples   Button btnBlank = new Button() Button btnClear = new Button ("OK"); Button btnDisplay = new Button("Display");
The ActionListener Interface   ,[object Object],[object Object],[object Object],[object Object]
Adding a Listener to the Component   ,[object Object],[object Object],[object Object],[object Object]
Coding for the Event   ,[object Object],[object Object],[object Object],[object Object],[object Object]
Mouse Events   ,[object Object],[object Object],[object Object],[object Object]
Mouse Events  Continued ,[object Object],[object Object],[object Object]
Other Listeners   ,[object Object],[object Object],[object Object]
The showStatus Method—General Format   showStatus(String);
The showStatus Method—Examples   showStatus("Click here to Calculate"); showStatus("Invalid entry");

More Related Content

What's hot

Variable and constants in Vb.NET
Variable and constants in Vb.NETVariable and constants in Vb.NET
Variable and constants in Vb.NET
Jaya Kumari
 
Chapter 9 python fundamentals
Chapter 9 python fundamentalsChapter 9 python fundamentals
Chapter 9 python fundamentals
Praveen M Jigajinni
 
Variables and calculations_chpt_4
Variables and calculations_chpt_4Variables and calculations_chpt_4
Variables and calculations_chpt_4
cmontanez
 
Python language data types
Python language data typesPython language data types
Python language data types
Hoang Nguyen
 
Python unit 2 M.sc cs
Python unit 2 M.sc csPython unit 2 M.sc cs
Python unit 2 M.sc cs
KALAISELVI P
 
Python basics
Python basicsPython basics
Python basics
Hoang Nguyen
 
Introduction To Programming with Python-3
Introduction To Programming with Python-3Introduction To Programming with Python-3
Introduction To Programming with Python-3
Syed Farjad Zia Zaidi
 
Programming in C sesion 2
Programming in C sesion 2Programming in C sesion 2
Programming in C sesion 2
Prerna Sharma
 
Python : Functions
Python : FunctionsPython : Functions
Data types in python
Data types in pythonData types in python
Data types in python
RaginiJain21
 
Keywords, identifiers and data type of vb.net
Keywords, identifiers and data type of vb.netKeywords, identifiers and data type of vb.net
Keywords, identifiers and data type of vb.net
Jaya Kumari
 
Python numbers
Python numbersPython numbers
Java execise
Java execiseJava execise
Java execise
Keneth miles
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
eShikshak
 
Basic data types in python
Basic data types in pythonBasic data types in python
Basic data types in python
sunilchute1
 
Generics collections
Generics collectionsGenerics collections
Generics collections
Yaswanth Babu Gummadivelli
 
Regular expressions in Python
Regular expressions in PythonRegular expressions in Python
Regular expressions in Python
Sujith Kumar
 

What's hot (17)

Variable and constants in Vb.NET
Variable and constants in Vb.NETVariable and constants in Vb.NET
Variable and constants in Vb.NET
 
Chapter 9 python fundamentals
Chapter 9 python fundamentalsChapter 9 python fundamentals
Chapter 9 python fundamentals
 
Variables and calculations_chpt_4
Variables and calculations_chpt_4Variables and calculations_chpt_4
Variables and calculations_chpt_4
 
Python language data types
Python language data typesPython language data types
Python language data types
 
Python unit 2 M.sc cs
Python unit 2 M.sc csPython unit 2 M.sc cs
Python unit 2 M.sc cs
 
Python basics
Python basicsPython basics
Python basics
 
Introduction To Programming with Python-3
Introduction To Programming with Python-3Introduction To Programming with Python-3
Introduction To Programming with Python-3
 
Programming in C sesion 2
Programming in C sesion 2Programming in C sesion 2
Programming in C sesion 2
 
Python : Functions
Python : FunctionsPython : Functions
Python : Functions
 
Data types in python
Data types in pythonData types in python
Data types in python
 
Keywords, identifiers and data type of vb.net
Keywords, identifiers and data type of vb.netKeywords, identifiers and data type of vb.net
Keywords, identifiers and data type of vb.net
 
Python numbers
Python numbersPython numbers
Python numbers
 
Java execise
Java execiseJava execise
Java execise
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
 
Basic data types in python
Basic data types in pythonBasic data types in python
Basic data types in python
 
Generics collections
Generics collectionsGenerics collections
Generics collections
 
Regular expressions in Python
Regular expressions in PythonRegular expressions in Python
Regular expressions in Python
 

Similar to Chapter2pp

Sharbani bhattacharya VB Structures
Sharbani bhattacharya VB StructuresSharbani bhattacharya VB Structures
Sharbani bhattacharya VB Structures
Sharbani Bhattacharya
 
Generics Collections
Generics CollectionsGenerics Collections
Generics Collections
phanleson
 
F# Console class
F# Console classF# Console class
F# Console class
DrRajeshreeKhande
 
C1320prespost
C1320prespostC1320prespost
C1320prespost
FALLEE31188
 
CIS-166 Midterm
CIS-166 MidtermCIS-166 Midterm
Midterm Winter 10
Midterm  Winter 10Midterm  Winter 10
unit 1 (1).pptx
unit 1 (1).pptxunit 1 (1).pptx
unit 1 (1).pptx
PriyadarshiniS28
 
C programming(part 3)
C programming(part 3)C programming(part 3)
C programming(part 3)
SURBHI SAROHA
 
Numerical data.
Numerical data.Numerical data.
Numerical data.
Adewumi Ezekiel Adebayo
 
Esoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programmingEsoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programming
Rasan Samarasinghe
 
CIS160 final review
CIS160 final reviewCIS160 final review
Cis160 Final Review
Cis160 Final ReviewCis160 Final Review
C++ - UNIT_-_IV.pptx which contains details about Pointers
C++ - UNIT_-_IV.pptx which contains details about PointersC++ - UNIT_-_IV.pptx which contains details about Pointers
C++ - UNIT_-_IV.pptx which contains details about Pointers
ANUSUYA S
 
Chapter 2
Chapter 2Chapter 2
I x scripting
I x scriptingI x scripting
I x scripting
Alex do Amaral Dias
 
Pengaturcaraan asas
Pengaturcaraan asasPengaturcaraan asas
Pengaturcaraan asas
Unit Kediaman Luar Kampus
 
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docxCS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
faithxdunce63732
 
Ap Power Point Chpt2
Ap Power Point Chpt2Ap Power Point Chpt2
Ap Power Point Chpt2
dplunkett
 
1_1_python-course-notes-sections-1-7.pdf
1_1_python-course-notes-sections-1-7.pdf1_1_python-course-notes-sections-1-7.pdf
1_1_python-course-notes-sections-1-7.pdf
Javier Crisostomo
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
HCMUTE
 

Similar to Chapter2pp (20)

Sharbani bhattacharya VB Structures
Sharbani bhattacharya VB StructuresSharbani bhattacharya VB Structures
Sharbani bhattacharya VB Structures
 
Generics Collections
Generics CollectionsGenerics Collections
Generics Collections
 
F# Console class
F# Console classF# Console class
F# Console class
 
C1320prespost
C1320prespostC1320prespost
C1320prespost
 
CIS-166 Midterm
CIS-166 MidtermCIS-166 Midterm
CIS-166 Midterm
 
Midterm Winter 10
Midterm  Winter 10Midterm  Winter 10
Midterm Winter 10
 
unit 1 (1).pptx
unit 1 (1).pptxunit 1 (1).pptx
unit 1 (1).pptx
 
C programming(part 3)
C programming(part 3)C programming(part 3)
C programming(part 3)
 
Numerical data.
Numerical data.Numerical data.
Numerical data.
 
Esoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programmingEsoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programming
 
CIS160 final review
CIS160 final reviewCIS160 final review
CIS160 final review
 
Cis160 Final Review
Cis160 Final ReviewCis160 Final Review
Cis160 Final Review
 
C++ - UNIT_-_IV.pptx which contains details about Pointers
C++ - UNIT_-_IV.pptx which contains details about PointersC++ - UNIT_-_IV.pptx which contains details about Pointers
C++ - UNIT_-_IV.pptx which contains details about Pointers
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
 
I x scripting
I x scriptingI x scripting
I x scripting
 
Pengaturcaraan asas
Pengaturcaraan asasPengaturcaraan asas
Pengaturcaraan asas
 
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docxCS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
CS 360 LAB 3 STRINGS, FUNCTIONS, AND METHODSObjective The purpos.docx
 
Ap Power Point Chpt2
Ap Power Point Chpt2Ap Power Point Chpt2
Ap Power Point Chpt2
 
1_1_python-course-notes-sections-1-7.pdf
1_1_python-course-notes-sections-1-7.pdf1_1_python-course-notes-sections-1-7.pdf
1_1_python-course-notes-sections-1-7.pdf
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 

More from J. C.

Apresentação processos e objetivos da alfabetização ciman 2013
Apresentação   processos e objetivos da alfabetização ciman  2013Apresentação   processos e objetivos da alfabetização ciman  2013
Apresentação processos e objetivos da alfabetização ciman 2013
J. C.
 
Uso de tecnologias
Uso de tecnologiasUso de tecnologias
Uso de tecnologias
J. C.
 
Tecnologias na educacao
Tecnologias na educacaoTecnologias na educacao
Tecnologias na educacao
J. C.
 
Pais maus
Pais mausPais maus
Pais maus
J. C.
 
A perícia médica a ética e a relação
A perícia médica a ética e a relaçãoA perícia médica a ética e a relação
A perícia médica a ética e a relação
J. C.
 
Quero
QueroQuero
Quero
J. C.
 
Pequeno prncipe
Pequeno prncipePequeno prncipe
Pequeno prncipe
J. C.
 
Ni
NiNi
Ni
J. C.
 
Meuanivers rio
Meuanivers rioMeuanivers rio
Meuanivers rio
J. C.
 
Sejascout
SejascoutSejascout
Sejascout
J. C.
 
Cartilha00
Cartilha00Cartilha00
Cartilha00
J. C.
 
Cartilha00
Cartilha00Cartilha00
Cartilha00
J. C.
 
Amor
AmorAmor
Amor
J. C.
 
Fotos gincana
Fotos gincanaFotos gincana
Fotos gincana
J. C.
 
Processo E Objetivos Da Alfabetização
Processo E Objetivos Da AlfabetizaçãoProcesso E Objetivos Da Alfabetização
Processo E Objetivos Da Alfabetização
J. C.
 
Fotografías
FotografíasFotografías
Fotografías
J. C.
 
Fotografías
FotografíasFotografías
Fotografías
J. C.
 
A Alma Da Mulher
A Alma Da MulherA Alma Da Mulher
A Alma Da Mulher
J. C.
 
Colegas de trabalho
Colegas de trabalhoColegas de trabalho
Colegas de trabalho
J. C.
 
Bem Vindo Ao Escoteiro
Bem Vindo Ao EscoteiroBem Vindo Ao Escoteiro
Bem Vindo Ao Escoteiro
J. C.
 

More from J. C. (20)

Apresentação processos e objetivos da alfabetização ciman 2013
Apresentação   processos e objetivos da alfabetização ciman  2013Apresentação   processos e objetivos da alfabetização ciman  2013
Apresentação processos e objetivos da alfabetização ciman 2013
 
Uso de tecnologias
Uso de tecnologiasUso de tecnologias
Uso de tecnologias
 
Tecnologias na educacao
Tecnologias na educacaoTecnologias na educacao
Tecnologias na educacao
 
Pais maus
Pais mausPais maus
Pais maus
 
A perícia médica a ética e a relação
A perícia médica a ética e a relaçãoA perícia médica a ética e a relação
A perícia médica a ética e a relação
 
Quero
QueroQuero
Quero
 
Pequeno prncipe
Pequeno prncipePequeno prncipe
Pequeno prncipe
 
Ni
NiNi
Ni
 
Meuanivers rio
Meuanivers rioMeuanivers rio
Meuanivers rio
 
Sejascout
SejascoutSejascout
Sejascout
 
Cartilha00
Cartilha00Cartilha00
Cartilha00
 
Cartilha00
Cartilha00Cartilha00
Cartilha00
 
Amor
AmorAmor
Amor
 
Fotos gincana
Fotos gincanaFotos gincana
Fotos gincana
 
Processo E Objetivos Da Alfabetização
Processo E Objetivos Da AlfabetizaçãoProcesso E Objetivos Da Alfabetização
Processo E Objetivos Da Alfabetização
 
Fotografías
FotografíasFotografías
Fotografías
 
Fotografías
FotografíasFotografías
Fotografías
 
A Alma Da Mulher
A Alma Da MulherA Alma Da Mulher
A Alma Da Mulher
 
Colegas de trabalho
Colegas de trabalhoColegas de trabalho
Colegas de trabalho
 
Bem Vindo Ao Escoteiro
Bem Vindo Ao EscoteiroBem Vindo Ao Escoteiro
Bem Vindo Ao Escoteiro
 

Recently uploaded

PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Zilliz
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Zilliz
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 

Recently uploaded (20)

PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 

Chapter2pp

  • 1. Chapter 2 Using Variables and Constants
  • 2.
  • 3. Applet Panel with Text Field, Text Area, and a Button
  • 4. Constructor Methods Constructor method executes automatically
  • 5.
  • 6.  
  • 7.
  • 8. Java Primitive Data Types Unicode character—a code designed for internationalization of applications char code 0 single character chr char -128 to 127 0 small integers byt byte true or false false true or false bln boolean Possible Values Default Initial Value Contents Naming Prefix Data Type
  • 9. Java Primitive Data Types Continued -32,768 to 32,767 0 short integer int short -9,223,372.036,854,775,808L to 9,223,372,036,854,775,807L 0 long integer lng long -2,147,483,648 to 2,147,483,647 0 integer data int int 7 digit precision 0.0 single precision floating point number flt float 15 digit precision 0.0 double precision floating point number dbl double
  • 10. Valid and Invalid Variable Names Accepted by Java but is a terrible identifier, since the name is not meaningful. valid X No periods allowed. invalid dblBig.Number Only letters, letters, and underscore characters allowed. No special characters. invalid fltBig# Must begin with a letter or underscore. invalid 2Times valid blnIsFinished valid chrLetter valid int_Person_Count No spaces allowed in a name. invalid int Person Count Reason Valid or Invalid Identifier
  • 11.
  • 12.
  • 13.
  • 14. Selected Java Data Type Wrapper Classes Integer Int Integer floating point numeric Flt Float True or False Bln Boolean character data str String Contents Naming Prefix DataType
  • 15. Scope and Lifetime of Variables New copy each time the method is called. Until the method ends. Visible only inside the method where it is declared. Inside a method. Local One copy for each object instantiated from the class. As long as this specific instance of the class exists. Visible in all methods of the class. Inside a class but not within a method. Instance One copy for the class. As long as any instance of the class exists. Visible in all methods of the class. Inside a class but not within a method. Keyword static . Class Memory allocated Lifetime Scope (Visibility) Location of Declaration Type
  • 16. The TextField Component—Constructor Formats TextField() TextField(int maximumNumberCharacters) TextField(String initialValue) TextField(String initialValue, int maximumNumberCharacters)
  • 17. The TextField Component—Examples TextField txtName = new TextField(20); TextField txtQuantity = new TextField(5); TextField txtZipCode = new TextField("91789"); TextField txtZipCode = new TextField("91789",9);
  • 18. The TextArea Component—Constructor Formats TextArea() TextArea(int numberRows, int maximumNumberCharacters) TextArea(String initialValue) TextArea(String initialValue, int numberRows, int maxNumberCharacters) TextArea(String initialValue, int numberRows, int maxNumberCharacters, int Scroll)
  • 19. The TextArea Component—Examples TextArea txaInvoice = new TextArea(20,40); TextArea txaGrades = new TextArea(15,20); TextArea txaGrade = new TextArea("Name Average",15, 20); TextArea txaGrade = new TextArea("Name Average", 15, 20, TextArea.SCROLLBARS_BOTH)
  • 20. Selected Methods of the TextField and TextArea Components Returns only the text that is selected in the text component. getSelectedText() Selects (highlights) the contents of the text component. selectAll() Adds text to the end of the contents, only available with TextArea. append() Assigns the value to the text component. setText(String value ) Returns the contents of the text component. getText() Purpose Method
  • 21. The getText Method—General Format componentName .getText()
  • 22. The getText Method —Example strName = txtName.getText();
  • 23. The setText Method—General Format componentName.setText(string to be displayed)
  • 24. The setText Method—Examples lblMessage.setText("Hello World"); txtGreeting.setText(strName); txtAnswer.setText("Hello " + txtName.getText()); txtName.setText(""); //Clear the text field
  • 25. Concatenation “ +” means concatenation of two items
  • 26.
  • 27. The append Method—General Format componentName .append( string );
  • 28. The Append Method—Examples txaInvoice.append("Sold To: " + strName +""); txaInvoice.append("Address: " + strStreet + ""); txaInvoice.append(" City: " + strCity);
  • 29. Use Unnamed Labels for Prompts Prompts
  • 30.
  • 31.
  • 32.
  • 33. Partial List of Calendar Integer Constants Minute of hour MINUTE Hour (12 hour time) HOUR BC or AD ERA Starts with 0 for Sunday DAY_OF_WEEK Julian date DAY_OF_YEAR Day starting with 1 DAY_OF_MONTH Month starting with 0 MONTH 4 digit year YEAR Returns Constant
  • 34. The Button Component—Constructor Formats Button() Button(String label );
  • 35. The Button Component—Examples Button btnBlank = new Button() Button btnClear = new Button ("OK"); Button btnDisplay = new Button("Display");
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42. The showStatus Method—General Format showStatus(String);
  • 43. The showStatus Method—Examples showStatus("Click here to Calculate"); showStatus("Invalid entry");