Java is a popular programming language created in 1995 that is used for mobile apps, desktop apps, web apps, servers, and more. It works across different platforms and is easy to learn and use. The document provides examples of how to write a simple "Hello World" Java program and how to declare and use variables of different data types like String, int, float, and boolean. It also covers Java operators.
What is Data Type?
Primitive Types in C#: Integer Types, Floating-Point Types, Decimal Type, Boolean Type, Character Types, Strings, Objects
Value Types and Reference Types
Variables. Using Variables: Declaring, Initializing, Assigning Value, Accessing Value
Literals: The Values of the Variables in the Source Code. Boolean Literals. Integer Literals. Floating-Point Literals, Decimal Literals, String Literals and Escaping Sequences
Exercises: Working with Primitive Types and Variables
Searching for Core Java and SQL free Online Course? To be a strong developer, start learning free online Java Courses and SQL tutorials that are excellent for beginners. Visit us @ https://www.brainsmartlabs.com/
This document discusses data types in C#. It explains that variables must be assigned a data type that specifies their size and values. The common data types covered are integer, floating point, boolean, character, and string. Integer types like int and long store whole numbers, while floating point types like float and double store fractional numbers. Boolean stores true/false values, char stores a single character, and string stores text. It also discusses type casting and conversion, where implicit casting automatically converts smaller types to larger ones, while explicit casting requires manually placing the type in parentheses. User input is covered, noting that ReadLine returns a string, so numerical input requires conversion to the correct type like Convert.ToInt32.
This document provides information about the C# programming language. It discusses that C# is an object-oriented language that can be used to build a variety of applications like Windows and web. Visual C# .NET is Microsoft's integrated development environment (IDE) for building C# applications and is part of the Visual Studio suite. The document also covers C# language fundamentals like variables, data types, operators, and conditional statements.
This document discusses Java variables, data types, and operators. It covers the basics of declaring variables in Java, including primitive and non-primitive data types. It also describes different types of variables, literals, casting, and operators such as arithmetic, assignment, comparison, and logical operators. Examples are provided to demonstrate variable declaration and usage of various operators.
This document provides an overview of key C# language concepts including variables and data types, arrays, array lists, enumerations, operators, type conversions, the DateTime and TimeSpan types, conditional logic, loops, methods, parameters, delegates, and comments. It describes basic syntax for these concepts and provides examples to illustrate their usage in C# code.
Three key points about the document:
1. Java has several primitive data types including boolean, char, byte, short, int, long, float, and double. Arrays allow grouping of multiple variables of the same type.
2. Arrays are dynamically allocated objects in Java. To create an array, the type and size must be specified using new, such as int[] numbers = new int[100]. Individual elements can then be accessed by index like numbers[25].
3. Type conversions may occur automatically between compatible types like int and long. Incompatible types require casting, such as (double)value to convert an int to a double. Arrays can be used to store and average multiple
The document discusses different types of loops in Java including while, do-while, and for loops. It provides the syntax for each loop and examples of how to use them. It also covers break and continue statements that can be used within loops. Finally, it briefly discusses methods in Java by defining what they are and providing the basic syntax for defining a method.
What is Data Type?
Primitive Types in C#: Integer Types, Floating-Point Types, Decimal Type, Boolean Type, Character Types, Strings, Objects
Value Types and Reference Types
Variables. Using Variables: Declaring, Initializing, Assigning Value, Accessing Value
Literals: The Values of the Variables in the Source Code. Boolean Literals. Integer Literals. Floating-Point Literals, Decimal Literals, String Literals and Escaping Sequences
Exercises: Working with Primitive Types and Variables
Searching for Core Java and SQL free Online Course? To be a strong developer, start learning free online Java Courses and SQL tutorials that are excellent for beginners. Visit us @ https://www.brainsmartlabs.com/
This document discusses data types in C#. It explains that variables must be assigned a data type that specifies their size and values. The common data types covered are integer, floating point, boolean, character, and string. Integer types like int and long store whole numbers, while floating point types like float and double store fractional numbers. Boolean stores true/false values, char stores a single character, and string stores text. It also discusses type casting and conversion, where implicit casting automatically converts smaller types to larger ones, while explicit casting requires manually placing the type in parentheses. User input is covered, noting that ReadLine returns a string, so numerical input requires conversion to the correct type like Convert.ToInt32.
This document provides information about the C# programming language. It discusses that C# is an object-oriented language that can be used to build a variety of applications like Windows and web. Visual C# .NET is Microsoft's integrated development environment (IDE) for building C# applications and is part of the Visual Studio suite. The document also covers C# language fundamentals like variables, data types, operators, and conditional statements.
This document discusses Java variables, data types, and operators. It covers the basics of declaring variables in Java, including primitive and non-primitive data types. It also describes different types of variables, literals, casting, and operators such as arithmetic, assignment, comparison, and logical operators. Examples are provided to demonstrate variable declaration and usage of various operators.
This document provides an overview of key C# language concepts including variables and data types, arrays, array lists, enumerations, operators, type conversions, the DateTime and TimeSpan types, conditional logic, loops, methods, parameters, delegates, and comments. It describes basic syntax for these concepts and provides examples to illustrate their usage in C# code.
Three key points about the document:
1. Java has several primitive data types including boolean, char, byte, short, int, long, float, and double. Arrays allow grouping of multiple variables of the same type.
2. Arrays are dynamically allocated objects in Java. To create an array, the type and size must be specified using new, such as int[] numbers = new int[100]. Individual elements can then be accessed by index like numbers[25].
3. Type conversions may occur automatically between compatible types like int and long. Incompatible types require casting, such as (double)value to convert an int to a double. Arrays can be used to store and average multiple
The document discusses different types of loops in Java including while, do-while, and for loops. It provides the syntax for each loop and examples of how to use them. It also covers break and continue statements that can be used within loops. Finally, it briefly discusses methods in Java by defining what they are and providing the basic syntax for defining a method.
The objective of the Level 5 Diploma in Information Technology is to provide learners with an excellent foundation for a career in a range of organisations. It designed to ensure that each learner is ‘business ready’: a confident, independent thinker with a detailed knowledge of Information Technology, and equipped with the skills to adapt rapidly to change.
The document discusses primitive data types in C#, including integer, floating-point, boolean, character, and string types. It defines each type, provides examples of declaring variables of each type and assigning values, and describes literals that can be used to represent values of different types. Key points covered include the name, size, and default value of each primitive type as well as demonstrations of declaring and initializing variables in C#.
This document provides information on data types in C++ programming. It begins by explaining that data types identify the type of data that can be stored in a variable, such as integer or boolean, and determine the possible values and operations for that type. It then describes several categories of data types in C++, including primitive, derived, user-defined, and examples of each. Primitive types are basic types predefined by the language like int, float, char. Derived types are built from primitive types, such as arrays and pointers. User-defined types allow creating new types and include enums, structures, and unions. The document provides examples of basic programs using various data types.
This document provides an introduction to the Java programming language. It discusses that Java is an object-oriented language created in 1995 that runs on many platforms and is used widely for mobile apps, web apps, and more. It also covers Java basics like installing Java, creating a "Hello World" program, using variables and data types, operators, strings, and comments.
variablesfinal-170820055428 data type resultsatifmugheesv
This document introduces variables, data types, and constants in C++. It defines a variable as a memory location used to store values. Variables are declared using a data type and identifier. Data types define a set of values and operations, and include basic types like int, char, float, and void. The document discusses the size, range, and examples of values for each data type. It also covers declaring and initializing variables as well as declaring constants in C++.
This document discusses Python data types and variables. It covers numeric data types like int and float, as well as Boolean, string, and sequence data types. It also defines what a variable is, how to name variables, and how to print and update variable values. It introduces type casting and the input function for getting user input.
This document discusses C++ comments, including single-line and multi-line comments. Single-line comments begin with // and multi-line comments begin with /* and end with */. It also covers basic data types in C++ like int, char, float, and double, as well as variables, constants, user input, operators, and identifiers.
This document provides an introduction to basic Java programming concepts including variables, data types, identifiers, keywords, comments, and outputting variable values. It discusses the different primitive data types in Java like int, double, char, etc. and how to declare and initialize variables of these types. The document also covers Java naming conventions for classes, methods and variables. It explains how to write single line, multi-line and javadoc comments. Finally, it demonstrates how to use System.out.println() and System.out.print() to output the values of variables.
This document provides an overview of data types in C++. It discusses fundamental data types like int, char, float, and void, as well as derived data types like arrays, functions, pointers, references, constants, classes, structures, unions, and enumerations. For each data type, it provides examples and explanations of how they are used and represented in memory. It also covers data type modifiers, variable declaration and initialization, and input/output stream manipulators for formatting output.
The second lecture of the ACM Aleppo CPC training. The local contest of ICPC. This lecture will help you get started in programming contests word with the lower bound techniques. The lectures focus on the C++ programming language and the STL library to solve programming problems.
The document discusses the different primitive and reference data types in Java, including their sizes, value ranges, and default values. It explains that variables are reserved memory locations used to store values and that reference variables are used to access objects of a specific class. The key Java primitive data types are byte, short, int, long, float, double, boolean, and char, each with their own characteristics for storing integer, floating point, boolean, or character values.
This document provides a summary of different data types in C programming language. It discusses basic data types like integer, floating point, character and void. It also explains derived data types like pointers, arrays, structures, unions and functions. For each data type, it provides the declaration syntax and examples to illustrate how they are used to declare variables of different types in C.
The document provides an introduction to data types in C++ programming language. It discusses the different levels of programming languages, common uses of C/C++, its character set, whitespace characters, and defines what a data type is. It then lists the primitive/built-in data types in C++ like integer, float, boolean, etc. and describes variables types and memory used. It also covers rules for constructing identifiers, variable declaration, and the four types of C/C++ instructions.
CIS 1403 Lab 2- Data Types and VariablesHamad Odhabi
This lab aims to develop the student knowledge and skills data types, required memory storage for each data type, selection of appropriate data types, naming variables, This lab aims to develop the student knowledge, and skills in identifying the appropriate data-types for variables, calculate the required memory storage for each data type, naming variables, casting of data types, and mathematic operations, the casting of data types, and arithmetic operations.
The document discusses various data types in C++. It explains that data types define the type of data stored in variables and associated operations. There are fundamental data types like integer, character, float, double, and void provided by C++. User-defined data types include arrays, pointers, references, structures, unions, classes and enumerations. The document provides details on the size and range of standard data types like short int, int, long, float, double etc. It also explains various type modifiers and derived data types.
The document defines and describes various data types in the C programming language. It discusses integer data types like char, short int, int, long int; floating point data types like float, double, long double; void data type; and derived data types like arrays, pointers, structures, unions, enumerated data types, and user-defined data types using typedef. Each data type is explained along with its size, range of values it can hold, and examples.
The objective of the Level 5 Diploma in Information Technology is to provide learners with an excellent foundation for a career in a range of organisations. It designed to ensure that each learner is ‘business ready’: a confident, independent thinker with a detailed knowledge of Information Technology, and equipped with the skills to adapt rapidly to change.
The document discusses primitive data types in C#, including integer, floating-point, boolean, character, and string types. It defines each type, provides examples of declaring variables of each type and assigning values, and describes literals that can be used to represent values of different types. Key points covered include the name, size, and default value of each primitive type as well as demonstrations of declaring and initializing variables in C#.
This document provides information on data types in C++ programming. It begins by explaining that data types identify the type of data that can be stored in a variable, such as integer or boolean, and determine the possible values and operations for that type. It then describes several categories of data types in C++, including primitive, derived, user-defined, and examples of each. Primitive types are basic types predefined by the language like int, float, char. Derived types are built from primitive types, such as arrays and pointers. User-defined types allow creating new types and include enums, structures, and unions. The document provides examples of basic programs using various data types.
This document provides an introduction to the Java programming language. It discusses that Java is an object-oriented language created in 1995 that runs on many platforms and is used widely for mobile apps, web apps, and more. It also covers Java basics like installing Java, creating a "Hello World" program, using variables and data types, operators, strings, and comments.
variablesfinal-170820055428 data type resultsatifmugheesv
This document introduces variables, data types, and constants in C++. It defines a variable as a memory location used to store values. Variables are declared using a data type and identifier. Data types define a set of values and operations, and include basic types like int, char, float, and void. The document discusses the size, range, and examples of values for each data type. It also covers declaring and initializing variables as well as declaring constants in C++.
This document discusses Python data types and variables. It covers numeric data types like int and float, as well as Boolean, string, and sequence data types. It also defines what a variable is, how to name variables, and how to print and update variable values. It introduces type casting and the input function for getting user input.
This document discusses C++ comments, including single-line and multi-line comments. Single-line comments begin with // and multi-line comments begin with /* and end with */. It also covers basic data types in C++ like int, char, float, and double, as well as variables, constants, user input, operators, and identifiers.
This document provides an introduction to basic Java programming concepts including variables, data types, identifiers, keywords, comments, and outputting variable values. It discusses the different primitive data types in Java like int, double, char, etc. and how to declare and initialize variables of these types. The document also covers Java naming conventions for classes, methods and variables. It explains how to write single line, multi-line and javadoc comments. Finally, it demonstrates how to use System.out.println() and System.out.print() to output the values of variables.
This document provides an overview of data types in C++. It discusses fundamental data types like int, char, float, and void, as well as derived data types like arrays, functions, pointers, references, constants, classes, structures, unions, and enumerations. For each data type, it provides examples and explanations of how they are used and represented in memory. It also covers data type modifiers, variable declaration and initialization, and input/output stream manipulators for formatting output.
The second lecture of the ACM Aleppo CPC training. The local contest of ICPC. This lecture will help you get started in programming contests word with the lower bound techniques. The lectures focus on the C++ programming language and the STL library to solve programming problems.
The document discusses the different primitive and reference data types in Java, including their sizes, value ranges, and default values. It explains that variables are reserved memory locations used to store values and that reference variables are used to access objects of a specific class. The key Java primitive data types are byte, short, int, long, float, double, boolean, and char, each with their own characteristics for storing integer, floating point, boolean, or character values.
This document provides a summary of different data types in C programming language. It discusses basic data types like integer, floating point, character and void. It also explains derived data types like pointers, arrays, structures, unions and functions. For each data type, it provides the declaration syntax and examples to illustrate how they are used to declare variables of different types in C.
The document provides an introduction to data types in C++ programming language. It discusses the different levels of programming languages, common uses of C/C++, its character set, whitespace characters, and defines what a data type is. It then lists the primitive/built-in data types in C++ like integer, float, boolean, etc. and describes variables types and memory used. It also covers rules for constructing identifiers, variable declaration, and the four types of C/C++ instructions.
CIS 1403 Lab 2- Data Types and VariablesHamad Odhabi
This lab aims to develop the student knowledge and skills data types, required memory storage for each data type, selection of appropriate data types, naming variables, This lab aims to develop the student knowledge, and skills in identifying the appropriate data-types for variables, calculate the required memory storage for each data type, naming variables, casting of data types, and mathematic operations, the casting of data types, and arithmetic operations.
The document discusses various data types in C++. It explains that data types define the type of data stored in variables and associated operations. There are fundamental data types like integer, character, float, double, and void provided by C++. User-defined data types include arrays, pointers, references, structures, unions, classes and enumerations. The document provides details on the size and range of standard data types like short int, int, long, float, double etc. It also explains various type modifiers and derived data types.
The document defines and describes various data types in the C programming language. It discusses integer data types like char, short int, int, long int; floating point data types like float, double, long double; void data type; and derived data types like arrays, pointers, structures, unions, enumerated data types, and user-defined data types using typedef. Each data type is explained along with its size, range of values it can hold, and examples.
This presentation includes basic of PCOS their pathology and treatment and also Ayurveda correlation of PCOS and Ayurvedic line of treatment mentioned in classics.
This presentation was provided by Steph Pollock of The American Psychological Association’s Journals Program, and Damita Snow, of The American Society of Civil Engineers (ASCE), for the initial session of NISO's 2024 Training Series "DEIA in the Scholarly Landscape." Session One: 'Setting Expectations: a DEIA Primer,' was held June 6, 2024.
বাংলাদেশের অর্থনৈতিক সমীক্ষা ২০২৪ [Bangladesh Economic Review 2024 Bangla.pdf] কম্পিউটার , ট্যাব ও স্মার্ট ফোন ভার্সন সহ সম্পূর্ণ বাংলা ই-বুক বা pdf বই " সুচিপত্র ...বুকমার্ক মেনু 🔖 ও হাইপার লিংক মেনু 📝👆 যুক্ত ..
আমাদের সবার জন্য খুব খুব গুরুত্বপূর্ণ একটি বই ..বিসিএস, ব্যাংক, ইউনিভার্সিটি ভর্তি ও যে কোন প্রতিযোগিতা মূলক পরীক্ষার জন্য এর খুব ইম্পরট্যান্ট একটি বিষয় ...তাছাড়া বাংলাদেশের সাম্প্রতিক যে কোন ডাটা বা তথ্য এই বইতে পাবেন ...
তাই একজন নাগরিক হিসাবে এই তথ্য গুলো আপনার জানা প্রয়োজন ...।
বিসিএস ও ব্যাংক এর লিখিত পরীক্ষা ...+এছাড়া মাধ্যমিক ও উচ্চমাধ্যমিকের স্টুডেন্টদের জন্য অনেক কাজে আসবে ...
How to Build a Module in Odoo 17 Using the Scaffold MethodCeline George
Odoo provides an option for creating a module by using a single line command. By using this command the user can make a whole structure of a module. It is very easy for a beginner to make a module. There is no need to make each file manually. This slide will show how to create a module using the scaffold method.
Executive Directors Chat Leveraging AI for Diversity, Equity, and InclusionTechSoup
Let’s explore the intersection of technology and equity in the final session of our DEI series. Discover how AI tools, like ChatGPT, can be used to support and enhance your nonprofit's DEI initiatives. Participants will gain insights into practical AI applications and get tips for leveraging technology to advance their DEI goals.
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...PECB
Denis is a dynamic and results-driven Chief Information Officer (CIO) with a distinguished career spanning information systems analysis and technical project management. With a proven track record of spearheading the design and delivery of cutting-edge Information Management solutions, he has consistently elevated business operations, streamlined reporting functions, and maximized process efficiency.
Certified as an ISO/IEC 27001: Information Security Management Systems (ISMS) Lead Implementer, Data Protection Officer, and Cyber Risks Analyst, Denis brings a heightened focus on data security, privacy, and cyber resilience to every endeavor.
His expertise extends across a diverse spectrum of reporting, database, and web development applications, underpinned by an exceptional grasp of data storage and virtualization technologies. His proficiency in application testing, database administration, and data cleansing ensures seamless execution of complex projects.
What sets Denis apart is his comprehensive understanding of Business and Systems Analysis technologies, honed through involvement in all phases of the Software Development Lifecycle (SDLC). From meticulous requirements gathering to precise analysis, innovative design, rigorous development, thorough testing, and successful implementation, he has consistently delivered exceptional results.
Throughout his career, he has taken on multifaceted roles, from leading technical project management teams to owning solutions that drive operational excellence. His conscientious and proactive approach is unwavering, whether he is working independently or collaboratively within a team. His ability to connect with colleagues on a personal level underscores his commitment to fostering a harmonious and productive workplace environment.
Date: May 29, 2024
Tags: Information Security, ISO/IEC 27001, ISO/IEC 42001, Artificial Intelligence, GDPR
-------------------------------------------------------------------------------
Find out more about ISO training and certification services
Training: ISO/IEC 27001 Information Security Management System - EN | PECB
ISO/IEC 42001 Artificial Intelligence Management System - EN | PECB
General Data Protection Regulation (GDPR) - Training Courses - EN | PECB
Webinars: https://pecb.com/webinars
Article: https://pecb.com/article
-------------------------------------------------------------------------------
For more information about PECB:
Website: https://pecb.com/
LinkedIn: https://www.linkedin.com/company/pecb/
Facebook: https://www.facebook.com/PECBInternational/
Slideshare: http://www.slideshare.net/PECBCERTIFICATION
2. What is Java?
Java is a popular programming language, created in 1995.
It is owned by Oracle, and more than 3 billion devices run Java.
It is used for:
• Mobile applications (specially Android apps)
• Desktop applications
• Web applications
• Web servers and application servers
• Games
• Database connection
• And much, much more
3. Why Use Java?
• Java works on different platforms (Windows, Mac, Linux, Raspberry
Pi, etc.)
• It is one of the most popular programming language in the world
• It is easy to learn and simple to use
• It is open-source and free
• It is secure, fast and powerful
• It has a huge community support (tens of millions of developers)
• Java is an object oriented language which gives a clear structure to
programs and allows code to be reused, lowering development costs
• As Java is close to C++ and C#, it makes it easy for programmers to
switch to Java or vice versa.
4. Java Quickstart
In Java, every application begins with a class name, and that class
must match the filename.
Let's create our first Java file, called Main.java, which can be done in
any text editor (like Notepad).
The file should contain a "Hello World" message, which is written with
the following code:
5. JAVA VARIABLES
Variables are containers for storing data values.
In Java, there are different types of variables, for example:
• String - stores text, such as "Hello". String values are surrounded by double
quotes
• int - stores integers (whole numbers), without decimals, such as 123 or -123
• float or double - stores floating point numbers, with decimals, such as 19.99
or -19.99
• char - stores single characters, such as 'a' or 'B'. Char values are surrounded
by single quotes
• boolean - stores values with two states: true or false
6. Declaring (Creating) Variables
To create a variable, you must specify the type and assign it a value:
Syntax
Where type is one of Java's types (such as int or String), and variable
is the name of the variable (such as x or name). The equal sign is used
to assign values to the variable.
To create a variable that should store text, look at the following
example:
Example
Create a variable called name of type String and assign it the
value "John":
type variable = value;
String name = "John";
System.out.println(name);
7. Declaring (Creating) Variables
To create a variable that should store a number, look at the following
example:
Example
Create a variable called myNum of type int and assign it the
value 15:
You can also declare a variable without assigning the value, and
assign the value later:
int myNum = 15;
System.out.println(myNum);
int myNum;
myNum = 15;
System.out.println(myNum);
8. Note that if you assign a new value to an existing variable, it will
overwrite the previous value:
Example
Change the value of myNum from 15 to 20:
Other declarations:
int myNum = 15;
myNum = 20; // myNum is now 20
System.out.println(myNum);
int myNum = 5; // Integer (whole number)
Double myDouble = 5.99; // Floating point number
char myLetter = 'D'; // Character
boolean myBool = true; // Boolean
String myText = "Hello"; // String
9. DATA TYPES
Data types are divided into two groups:
• Primitive data types - includes byte, short, int, long, float, double, boolean
and char
• Non-primitive data types - such as String, Arrays and Classes (you will learn
more about these in a later chapter)
10. Primitive Data Types
A primitive data type specifies the size and type of variable values,
and it has no additional methods.
There are eight primitive data types in Java:
Data Type Size Description
byte 1 byte Stores whole numbers from -128 to 127
short 2 bytes Stores whole numbers from -32,768 to 32,767
int 4 bytes Stores whole numbers from -2,147,483,648 to 2,147,483,647
long 8 bytes Stores whole numbers from -9,223,372,036,854,775,808 to
9,223,372,036,854,775,807
float 4 bytes Stores fractional numbers. Sufficient for storing 6 to 7 decimal digits
double 8 bytes Stores fractional numbers. Sufficient for storing 15 decimal digits
boolean 1 bit Stores true or false values
char 2 bytes Stores a single character/letter or ASCII values
11. Numbers
Primitive number types are divided into two groups:
• Integer types stores whole numbers, positive or negative (such as
123 or -456), without decimals. Valid types are byte, short, int and
long. Which type you should use, depends on the numeric value.
• Floating point types represents numbers with a fractional part,
containing one or more decimals. There are two types: float and
double.
12. Integer Types
Byte
The byte data type can store whole numbers from -128 to 127. This
can be used instead of int or other integer types to save memory
when you are certain that the value will be within -128 and 127:
Short
The short data type can store whole numbers from -32768 to 32767:
byte myNum = 100;
System.out.println(myNum);
short myNum = 5000;
System.out.println(myNum);
13. Integer Types
Int
The int data type can store whole numbers from -2147483648 to
2147483647. In general, and in our tutorial, the int data type is the
preferred data type when we create variables with a numeric value.
Long
The long data type can store whole numbers from -
9223372036854775808 to 9223372036854775807. This is used when
int is not large enough to store the value. Note that you should end
the value with an "L":
int myNum = 100000;
System.out.println(myNum);
long myNum = 15000000000L;
System.out.println(myNum);
14. Floating Point Types
You should use a floating point type whenever you need a number
with a decimal, such as 9.99 or 3.14515.
Float
The float data type can store fractional numbers from 3.4e−038 to
3.4e+038. Note that you should end the value with an "f":
Double
The double data type can store fractional numbers from 1.7e−308 to
1.7e+308. Note that you should end the value with a "d":
float myNum = 5.75f;
System.out.println(myNum);
double myNum = 19.99d;
System.out.println(myNum);
15. Floating Point Types
Use float or double?
The precision of a floating point value indicates how many digits the value can
have after the decimal point. The precision of float is only six or seven decimal
digits, while double variables have a precision of about 15 digits. Therefore it is
safer to use double for most calculations.
16. Floating Point Types
You should use a floating point type whenever you need a number
with a decimal, such as 9.99 or 3.14515.
Float
The float data type can store fractional numbers from 3.4e−038 to
3.4e+038. Note that you should end the value with an "f":
Double
The double data type can store fractional numbers from 1.7e−308 to
1.7e+308. Note that you should end the value with a "d":
float myNum = 5.75f;
System.out.println(myNum);
double myNum = 19.99d;
System.out.println(myNum);
17. Booleans
A boolean data type is declared with the boolean keyword and can only take the
values true or false:
Characters
The char data type is used to store a single character. The character must be
surrounded by single quotes, like 'A' or 'c':
boolean isJavaFun = true;
boolean isFishTasty = false;
System.out.println(isJavaFun); // Outputs true
System.out.println(isFishTasty); // Outputs false
char myGrade = 'B';
System.out.println(myGrade);
18. Strings
The String data type is used to store a sequence of characters (text). String values
must be surrounded by double quotes:
String greeting = "Hello World";
System.out.println(greeting);
19. JAVA OPERATORS
• Operators are used to perform operations on variables and values.
In the example below, we use the + operator to add together two values:
int x = 100 + 50;
Although the + operator is often used to add together two values, like in the
example above, it can also be used to add together a variable and a value, or
a variable and another variable:
int sum1 = 100 + 50; // 150 (100 + 50)
int sum2 = sum1 + 250; // 400 (150 + 250)
int sum3 = sum2 + sum2; // 800 (400 + 400)