The document discusses Java syntax and concepts including:
1. It introduces primitive data types in Java like int, float, boolean and String.
2. It covers variables, operators, and expressions - how they are used to store and manipulate data in Java.
3. It explains console input and output using Scanner and System.out methods for reading user input and printing output.
4. It provides examples of using conditional statements like if and if-else to control program flow based on conditions.
In this chapter we will get familiar with primitive types and variables in Java – what they are and how to work with them. First we will consider the data types – integer types, real types with floating-point, Boolean, character, string and object type. We will continue with the variables, with their characteristics, how to declare them, how they are assigned a value and what is variable initialization.
19. Data Structures and Algorithm ComplexityIntro C# Book
In this chapter we will compare the data structures we have learned so far by the performance (execution speed) of the basic operations (addition, search, deletion, etc.). We will give specific tips in what situations what data structures to use. We will explain how to choose between data structures like hash-tables, arrays, dynamic arrays and sets implemented by hash-tables or balanced trees. Almost all of these structures are implemented as part of NET Framework, so to be able to write efficient and reliable code we have to learn to apply the most appropriate structures for each situation.
Here we are going to take a look how to use for loop, foreach loop and while loop. Also we are going to learn how to use and invoke methods and how to define classes in Java programming language.
In this chapter we will explore strings. We are going to explain how they are implemented in C# and in what way we can process text content. Additionally, we will go through different methods for manipulating a text: we will learn how to compare strings, how to search for substrings, how to extract substrings upon previously settled parameters and last but not least how to split a string by separator chars. We will demonstrate how to correctly build strings with the StringBuilder class. We will provide a short but very useful information for the most commonly used regular expressions. We will discuss some classes for efficient construction of strings. Finally, we will take a look at the methods and classes for achieving more elegant and stricter formatting of the text content.
In this chapter we will get more familiar with what methods are and why we need to use them. The reader will be shown how to declare methods, what parameters are and what a method’s signature is, how to call a method, how to pass arguments of methods and how methods return values. At the end of this chapter we will know how to create our own method and how to use (invoke) it whenever necessary. Eventually, we will suggest some good practices in working with methods. The content of this chapter accompanied by detailed examples and exercises that will help the reader practice the learned material.
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
In this chapter we will get familiar with primitive types and variables in Java – what they are and how to work with them. First we will consider the data types – integer types, real types with floating-point, Boolean, character, string and object type. We will continue with the variables, with their characteristics, how to declare them, how they are assigned a value and what is variable initialization.
19. Data Structures and Algorithm ComplexityIntro C# Book
In this chapter we will compare the data structures we have learned so far by the performance (execution speed) of the basic operations (addition, search, deletion, etc.). We will give specific tips in what situations what data structures to use. We will explain how to choose between data structures like hash-tables, arrays, dynamic arrays and sets implemented by hash-tables or balanced trees. Almost all of these structures are implemented as part of NET Framework, so to be able to write efficient and reliable code we have to learn to apply the most appropriate structures for each situation.
Here we are going to take a look how to use for loop, foreach loop and while loop. Also we are going to learn how to use and invoke methods and how to define classes in Java programming language.
In this chapter we will explore strings. We are going to explain how they are implemented in C# and in what way we can process text content. Additionally, we will go through different methods for manipulating a text: we will learn how to compare strings, how to search for substrings, how to extract substrings upon previously settled parameters and last but not least how to split a string by separator chars. We will demonstrate how to correctly build strings with the StringBuilder class. We will provide a short but very useful information for the most commonly used regular expressions. We will discuss some classes for efficient construction of strings. Finally, we will take a look at the methods and classes for achieving more elegant and stricter formatting of the text content.
In this chapter we will get more familiar with what methods are and why we need to use them. The reader will be shown how to declare methods, what parameters are and what a method’s signature is, how to call a method, how to pass arguments of methods and how methods return values. At the end of this chapter we will know how to create our own method and how to use (invoke) it whenever necessary. Eventually, we will suggest some good practices in working with methods. The content of this chapter accompanied by detailed examples and exercises that will help the reader practice the learned material.
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
In this chapter we are going to get familiar with recursion and its applications. Recursion represents a powerful programming technique in which a method makes a call to itself from within its own method body. By means of recursion we can solve complicated combinatorial problems, in which we can easily exhaust different combinatorial configurations, e.g. generating permutations and variations and simulating nested loops. We are going to demonstrate many examples of correct and incorrect usage of recursion and convince you how useful it can be.
In this chapter we will explore strings. We are going to explain how they are implemented in Java and in what way we can process text content. Additionally, we will go through different methods for manipulating a text: we will learn how to compare strings, how to search for substrings, how to extract substrings upon previously settled parameters and last but not least how to split a string by separator chars. We will demonstrate how to correctly build strings with the StringBuilder class. We will provide a short but very useful information for the most commonly used regular expressions.
In this chapter we will discuss exceptions in the object-oriented programming and in C# in particular. We will learn how to handle exceptions using the try-catch construct, how to pass them to the calling methods and how to throw standard or our own exceptions using the throw construct. We will give various examples for using exceptions. We will look at the types of exceptions and the exceptions hierarchy in the .NET Framework. At the end, we will look at the advantages of using exceptions, best practices and how to apply them in different situations.
In this chapter we will examine the loop programming constructs through which we can execute a code snippet repeatedly. We will discuss how to implement conditional repetitions (while and do-while loops) and how to work with for-loops. We will give examples of different possibilities to define loops, how to construct them and some of their key usages. Finally, we will discuss the foreach-loop construct and how we can use multiple loops placed inside each other (nested loops).
In this lesson you will learn how to use basic syntax, conditions, if-else statements and loops (for-loop, while-loop and do-while-loop) in Java and how to use the debugger.
Watch the video lesson and access the hands-on exercises here: https://softuni.org/code-lessons/java-foundations-certification-basic-syntax-conditions-and-loops
In this chapter we will get familiar with the console as a tool for data input and output. We will explain what it is, when and how to use it, and how most programming languages access the console. We will get familiar with some of the features in C# for user interaction: reading text and numbers from the console and printing text and numbers. We will also examine the main streams for input-output operations Console.In, Console.Out and Console.Error, the Console and the usage of format strings for printing data in various formats.
In this chapter we are going to get familiar with some of the basic presentations of data in programming: lists and linear data structures. Very often in order to solve a given problem we need to work with a sequence of elements. For example, to read completely this book we have to read sequentially each page, i.e. to traverse sequentially each of the elements of the set of the pages in the book. Depending on the task, we have to apply different operations on this set of data. In this chapter we will introduce the concept of abstract data types (ADT) and will explain how a certain ADT can have multiple different implementations. After that we shall explore how and when to use lists and their implementations (linked list, doubly-linked list and array-list). We are going to see how for a given task one structure may be more convenient than another. We are going to consider the structures "stack" and "queue", as well as their applications. We are going to get familiar with some implementations of these structures.
In this chapter we will discuss exceptions in the object-oriented programming and in Java in particular. We will learn how to handle exceptions using the try-catch construct, how to pass them to the calling methods and how to throw standard or our own exceptions using the throw construct.
In this chapter we will review how to work with text files in C#. We will explain what a stream is, what its purpose is, and how to use it. We will explain what a text file is and how can you read and write data to a text file and how to deal with different character encodings. We will demonstrate and explain the good practices for exception handling when working with files. All of this will be demonstrated with many examples in this chapter
This code lesson teaches the first steps in coding with Java: writing code commands, running the code, writing Java programs. It comes with practical hands-on exercises with automated grading.
Learn more at https://softuni.org/code-lessons/java-tutorial-part-1-getting-started-with-java
In this chapter we will learn about arrays as a way to work with sequences of elements of the same type. We will explain what arrays are, how we declare, create, instantiate and use them. We will examine one-dimensional and multidimensional arrays. We will learn different ways to iterate through the array, read from the standard input and write to the standard output. We will give many example exercises, which can be solved using arrays and we will show how useful they really are.
ESOFT Metro Campus - Diploma in Software Engineering - (Module VI) Windows Based Application Development in Java
(Template - Virtusa Corporate)
Contents:
Introduction to Java
Features of Java
What you can create by Java?
Start Java Programming
Creating First Java Program
Java Virtual Machine
Basic Rules to Remember
Keywords in Java
Comments in Java Programs
Printing Statements
Primitive Data Types in Java
Arithmetic Operators
Assignment Operators
Comparison Operators
Logical Operators
If Statement
If… Else Statement
If… Else if… Else Statement
Nested If Statement
While Loop
Do While Loop
For Loop
Reading User Input
Arrays
Two Dimensional Arrays
Strings
Objects and Classes
Java Classes
Java Objects
Methods with Return Value
Methods without Return Value
Constructors
Method Overloading
Variable Types
Inheritance
Method Overriding
Abstract Classes
Interfaces
Polymorphism
Packages
Access Modifiers
Encapsulation
Exceptions
JDBC
GUI Applications with Swing
NetBeans IDE
Java Foundations: Data Types and Type ConversionSvetlin Nakov
Learn how to use data types and variables in Java, how variables are stored in the memory and how to convert from one data type to another.
Watch the video lesson and access the hands-on exercises here: https://softuni.org/code-lessons/java-foundations-certification-data-types-and-variables
In this chapter we are going to get familiar with recursion and its applications. Recursion represents a powerful programming technique in which a method makes a call to itself from within its own method body. By means of recursion we can solve complicated combinatorial problems, in which we can easily exhaust different combinatorial configurations, e.g. generating permutations and variations and simulating nested loops. We are going to demonstrate many examples of correct and incorrect usage of recursion and convince you how useful it can be.
In this chapter we will explore strings. We are going to explain how they are implemented in Java and in what way we can process text content. Additionally, we will go through different methods for manipulating a text: we will learn how to compare strings, how to search for substrings, how to extract substrings upon previously settled parameters and last but not least how to split a string by separator chars. We will demonstrate how to correctly build strings with the StringBuilder class. We will provide a short but very useful information for the most commonly used regular expressions.
In this chapter we will discuss exceptions in the object-oriented programming and in C# in particular. We will learn how to handle exceptions using the try-catch construct, how to pass them to the calling methods and how to throw standard or our own exceptions using the throw construct. We will give various examples for using exceptions. We will look at the types of exceptions and the exceptions hierarchy in the .NET Framework. At the end, we will look at the advantages of using exceptions, best practices and how to apply them in different situations.
In this chapter we will examine the loop programming constructs through which we can execute a code snippet repeatedly. We will discuss how to implement conditional repetitions (while and do-while loops) and how to work with for-loops. We will give examples of different possibilities to define loops, how to construct them and some of their key usages. Finally, we will discuss the foreach-loop construct and how we can use multiple loops placed inside each other (nested loops).
In this lesson you will learn how to use basic syntax, conditions, if-else statements and loops (for-loop, while-loop and do-while-loop) in Java and how to use the debugger.
Watch the video lesson and access the hands-on exercises here: https://softuni.org/code-lessons/java-foundations-certification-basic-syntax-conditions-and-loops
In this chapter we will get familiar with the console as a tool for data input and output. We will explain what it is, when and how to use it, and how most programming languages access the console. We will get familiar with some of the features in C# for user interaction: reading text and numbers from the console and printing text and numbers. We will also examine the main streams for input-output operations Console.In, Console.Out and Console.Error, the Console and the usage of format strings for printing data in various formats.
In this chapter we are going to get familiar with some of the basic presentations of data in programming: lists and linear data structures. Very often in order to solve a given problem we need to work with a sequence of elements. For example, to read completely this book we have to read sequentially each page, i.e. to traverse sequentially each of the elements of the set of the pages in the book. Depending on the task, we have to apply different operations on this set of data. In this chapter we will introduce the concept of abstract data types (ADT) and will explain how a certain ADT can have multiple different implementations. After that we shall explore how and when to use lists and their implementations (linked list, doubly-linked list and array-list). We are going to see how for a given task one structure may be more convenient than another. We are going to consider the structures "stack" and "queue", as well as their applications. We are going to get familiar with some implementations of these structures.
In this chapter we will discuss exceptions in the object-oriented programming and in Java in particular. We will learn how to handle exceptions using the try-catch construct, how to pass them to the calling methods and how to throw standard or our own exceptions using the throw construct.
In this chapter we will review how to work with text files in C#. We will explain what a stream is, what its purpose is, and how to use it. We will explain what a text file is and how can you read and write data to a text file and how to deal with different character encodings. We will demonstrate and explain the good practices for exception handling when working with files. All of this will be demonstrated with many examples in this chapter
This code lesson teaches the first steps in coding with Java: writing code commands, running the code, writing Java programs. It comes with practical hands-on exercises with automated grading.
Learn more at https://softuni.org/code-lessons/java-tutorial-part-1-getting-started-with-java
In this chapter we will learn about arrays as a way to work with sequences of elements of the same type. We will explain what arrays are, how we declare, create, instantiate and use them. We will examine one-dimensional and multidimensional arrays. We will learn different ways to iterate through the array, read from the standard input and write to the standard output. We will give many example exercises, which can be solved using arrays and we will show how useful they really are.
ESOFT Metro Campus - Diploma in Software Engineering - (Module VI) Windows Based Application Development in Java
(Template - Virtusa Corporate)
Contents:
Introduction to Java
Features of Java
What you can create by Java?
Start Java Programming
Creating First Java Program
Java Virtual Machine
Basic Rules to Remember
Keywords in Java
Comments in Java Programs
Printing Statements
Primitive Data Types in Java
Arithmetic Operators
Assignment Operators
Comparison Operators
Logical Operators
If Statement
If… Else Statement
If… Else if… Else Statement
Nested If Statement
While Loop
Do While Loop
For Loop
Reading User Input
Arrays
Two Dimensional Arrays
Strings
Objects and Classes
Java Classes
Java Objects
Methods with Return Value
Methods without Return Value
Constructors
Method Overloading
Variable Types
Inheritance
Method Overriding
Abstract Classes
Interfaces
Polymorphism
Packages
Access Modifiers
Encapsulation
Exceptions
JDBC
GUI Applications with Swing
NetBeans IDE
Java Foundations: Data Types and Type ConversionSvetlin Nakov
Learn how to use data types and variables in Java, how variables are stored in the memory and how to convert from one data type to another.
Watch the video lesson and access the hands-on exercises here: https://softuni.org/code-lessons/java-foundations-certification-data-types-and-variables
Esoft Metro Campus - Diploma in Information Technology - (Module IX) Programming with C#.NET
(Template - Virtusa Corporate)
Contents:
Introduction to .NET Framework
.NET Framework Platform Architecture
Microsoft Visual Studio
C# Language
C#, VS and .NET Framework Versions
Your First C# Application
Printing Statements
Comments in C#
Common Type System
Value Types and Reference Type
Variables Declaration in C#
Type Conversion
Arithmetic Operators
Assignment Operators
Comparison Operators
Logical Operators
If Statement
If… Else Statement
If… Else if… Else Statement
Nested If Statement
Switch Statement
While Loop
Do While Loop
For Loop
Arrays
Accessing Arrays using foreach Loop
Two Dimensional Arrays
Classes and Objects in C#
Inheritance in C#
Partial Classes
Namespaces
Windows Forms Applications
Using Buttons, Labels and Text Boxes
Displaying Message Boxes
Error Handling with Try… Catch… finally…
Using Radio Buttons
Using Check Boxes
Using List Boxes
Creating Menus
Creating ToolStrips
MDI Forms
Database Application in C#
Creating a Simple Database Application
SQL Insert / Update / Retrieving / Delete
SQL Command Execute Methods
Data Sets
Presented By:
N.V.Raja Sekhar Reddy
www.technolamp.co.in
Want more interesting...
Watch and Like us @ https://www.facebook.com/Technolamp.co.in
subscribe videos @ http://www.youtube.com/user/nvrajasekhar
ESOFT Metro Campus - Diploma in Software Engineering - (Module V) Windows Based Application Development in C#
(Template - Virtusa Corporate)
Contents:
Introduction to .NET Framework
.NET Framework Platform Architecture
Microsoft Visual Studio
C# Language
C#, VS and .NET Framework Versions
Your First C# Application
Printing Statements
Comments in C#
Common Type System
Value Types and Reference Type
Variables Declaration in C#
Type Conversion
Arithmetic Operators
Assignment Operators
Comparison Operators
Logical Operators
If Statement
If… Else Statement
If… Else if… Else Statement
Nested If Statement
Switch Statement
While Loop
Do While Loop
For Loop
Arrays
Accessing Arrays using foreach Loop
Two Dimensional Arrays
Classes and Objects in C#
Inheritance in C#
Partial Classes
Namespaces
Windows Forms Applications
Using Buttons, Labels and Text Boxes
Displaying Message Boxes
Error Handling with Try… Catch… finally…
Using Radio Buttons
Using Check Boxes
Using List Boxes
Creating Menus
Creating ToolStrips
MDI Forms
Database Application in C#
Creating a Simple Database Application
SQL Insert / Update / Retrieving / Delete
SQL Command Execute Methods
Data Sets
Esoft Metro Campus - Certificate in c / c++ programmingRasan Samarasinghe
Esoft Metro Campus - Certificate in java basics
(Template - Virtusa Corporate)
Contents:
Structure of a program
Variables & Data types
Constants
Operators
Basic Input/output
Control Structures
Functions
Arrays
Character Sequences
Pointers and Dynamic Memory
Unions
Other Data Types
Input/output with files
Searching
Sorting
Introduction to data structures
Similar to 03 and 04 .Operators, Expressions, working with the console and conditional statements (20)
17. Java data structures trees representation and traversalIntro C# Book
In this chapter we will discuss tree data structures, like trees and graphs. The abilities of these data structures are really important for the modern programming. Each of this data structures is used for building a model of real life problems, which are efficiently solved using this model.
In this chapter we will discuss one recommended practice for efficiently solving computer programming problems and make a demonstration with appropriate examples. We will discuss the basic engineering principles of problem solving, why we should follow them when solving computer programming problems (the same principles can also be applied to find the solutions of many mathematical and scientific problems as well) and we will make an example of their use. We will describe the steps, in which we should go in order to solve some sample problems and show the mistakes that can occur when we do not follow these same steps. We will pay attention to some important steps from the methodology of problem solving, that we usually skip, e.g. the testing. We hope to be able to prove you, with proper examples, that the solving of computer programming problems has a "recipe" and it is very useful.
In this chapter we review the basic rules and recommendations for writing quality program code. We pay attention to naming the identifiers in the program (variables, methods, parameters, classes, etc.), formatting and code organization rules, good practices for composing methods, and principles for writing quality documentation.
Here we are going to learn why is a good practice to use interfaces and how they are different from abstraction classes. Further more we are going to see how which one of them to use.
19. Java data structures algorithms and complexityIntro C# Book
In this chapter we will compare the data structures we have learned so far by the performance (execution speed) of the basic operations (addition, search, deletion, etc.). We will give specific tips in what situations what data structures to use.
In this chapter we will understand how to define custom classes and their elements. We will learn to declare fields, constructors and properties for the classes. We will revise what a method is and we will broaden our knowledge about access modifiers and methods.
01. Introduction to programming with javaIntro C# Book
In this chapter we will take a look at the basic programming terminology and we will write our first Java program. We will familiarize ourselves with programming – what it means and its connection to computers and programming languages.
In this chapter we will discuss one recommended practice for efficiently solving computer programming problems and make a demonstration with appropriate examples. We will discuss the basic engineering principles of problem solving, why we should follow them when solving computer programming problems (the same principles can also be applied to find the solutions of many mathematical and scientific problems as well) and we will make an example of their use. We will describe the steps, in which we should go in order to solve some sample problems and show the mistakes that can occur when we do not follow these same steps. We will pay attention to some important steps from the methodology of problem solving, that we usually skip, e.g. the testing. We hope to be able to prove you, with proper examples, that the solving of computer programming problems has a "recipe" and it is very useful
Chapter 22. Lambda Expressions and LINQIntro C# Book
In this chapter we will become acquainted with some of the advanced capabilities of the C# language. To be more specific, we will pay attention on how to make queries to collections, using lambda expressions and LINQ, and how to add functionality to already created classes, using extension methods. We will get to know the anonymous types, describe their usage briefly and discuss lambda expressions and show in practice how most of the built-in lambda functions work. Afterwards, we will pay more attention to the LINQ syntax – we will learn what it is, how it works and what queries we can build with it. In the end, we will get to know the meaning of the keywords in LINQ, and demonstrate their capabilities with lots of examples.
In this chapter we review the basic rules and recommendations for writing quality program code. We pay attention to naming the identifiers in the program (variables, methods, parameters, classes, etc.), formatting and code organization rules, good practices for composing methods, and principles for writing quality documentation. We describe the official "Design Guidelines for Developing Class Libraries for .NET" from Microsoft. In the meantime we explain how the programming environment can automate operations such as code formatting and refactoring.
This chapter is a kind of continuation of the previous one – “Object-Oriented Programming Principles”. The reader is expected to be familiar with the basic OOP principles: abstraction, inheritance, polymorphism, encapsulation and exception handling. Those do greatly affect the quality of the code.
In this chapter we will analyze more complex data structures like dictionaries and sets, and their implementations with hash-tables and balanced trees. We will explain in more details what hashing and hash-tables mean and why they are such an important part of programming. We will discuss the concept of "collisions" and how they might happen when implementing hash-tables. Also we will offer you different types of approaches for solving this type of issues. We will look at the abstract data structure set and explain how it can be implemented with the ADTs dictionary and balanced search tree. Also we will provide you with examples that illustrate the behavior of these data structures with real world examples.
In this chapter we will discuss tree data structures, like trees and graphs. The abilities of these data structures are really important for the modern programming. Each of this data structures is used for building a model of real life problems, which are efficiently solved using this model. We will explain what tree data structures are and will review their main advantages and disadvantages. We will present example implementations and problems showing their practical usage. We will focus on binary trees, binary search trees and self-balancing binary search tree. We will explain what graph is, the types of graphs, how to represent a graph in the memory (graph implementation) and where graphs are used in our life and in the computer technologies. We will see where in .NET Framework self-balancing binary search trees are implemented and how to use them.
In this chapter we will understand how to define custom classes and their elements. We will learn to declare fields, constructors and properties for the classes. We will revise what a method is and we will broaden our knowledge about access modifiers and methods. We will observe the characteristics of the constructors and we will set out how the program objects coexist in the dynamic memory and how their fields are initialized. Finally, we will explain what the static elements of a class are – fields (including constants), properties and methods and how to use them properly. In this chapter we will also introduce generic types (generics), enumerated types (enumerations) and nested classes.
1.Wireless Communication System_Wireless communication is a broad term that i...JeyaPerumal1
Wireless communication involves the transmission of information over a distance without the help of wires, cables or any other forms of electrical conductors.
Wireless communication is a broad term that incorporates all procedures and forms of connecting and communicating between two or more devices using a wireless signal through wireless communication technologies and devices.
Features of Wireless Communication
The evolution of wireless technology has brought many advancements with its effective features.
The transmitted distance can be anywhere between a few meters (for example, a television's remote control) and thousands of kilometers (for example, radio communication).
Wireless communication can be used for cellular telephony, wireless access to the internet, wireless home networking, and so on.
ER(Entity Relationship) Diagram for online shopping - TAEHimani415946
https://bit.ly/3KACoyV
The ER diagram for the project is the foundation for the building of the database of the project. The properties, datatypes, and attributes are defined by the ER diagram.
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesSanjeev Rampal
Talk presented at Kubernetes Community Day, New York, May 2024.
Technical summary of Multi-Cluster Kubernetes Networking architectures with focus on 4 key topics.
1) Key patterns for Multi-cluster architectures
2) Architectural comparison of several OSS/ CNCF projects to address these patterns
3) Evolution trends for the APIs of these projects
4) Some design recommendations & guidelines for adopting/ deploying these solutions.
This 7-second Brain Wave Ritual Attracts Money To You.!nirahealhty
Discover the power of a simple 7-second brain wave ritual that can attract wealth and abundance into your life. By tapping into specific brain frequencies, this technique helps you manifest financial success effortlessly. Ready to transform your financial future? Try this powerful ritual and start attracting money today!
2. 2
1. Primitive Data Types
2. Variables
3. Operators
4. Expressions
5. Statements
6. Console-Based Input and Output
7. Conditional Statements
if-else, switch-case, …
Table of Contents
3. 3
The "Java Basics" course is NOT for absolute beginners
Take the "C# Basics" course at SoftUni first:
https://softuni.bg/courses/csharp-basics
The course is for beginners, but with previous coding skills
Requirements
Coding skills – entry level
Computer English – entry level
Logical thinking
Warning: Not for Absolute Beginners
5. 5
Computers are machines that process data
Data is stored in the computer memory in variables
Variables have name, data type and value
Example of variable definition and assignment in Java
When processed, data is stored back into variables
How Computing Works?
int count = 5;Data type
Variable name
Variable value
6. 6
A data type:
Is a domain of values of similar characteristics
Defines the type of information stored in the
computer memory (in a variable)
Examples:
Positive integers: 1, 2, 3, …
Alphabetical characters: a, b, c, …
Days of week: Monday, Tuesday, …
What Is a Data Type?
7. 7
A data type has:
Name (Java keyword, e.g. int)
Size (how much memory is used)
Default value
Example:
Integer numbers in C#
Name: int
Size: 32 bits (4 bytes)
Default value: 0
Data Type Characteristics
int: sequence of 32
bits in the memory
int: 4 sequential
bytes in the memory
8. 8
byte (-128 to 127): signed 8-bit
short (-32,768 to 32,767): signed 16-bit
int (-2,147,483,648 to 2,147,483,647): signed 32-bit
long (-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807):
signed 64-bit
Integer Types
byte b = 1;
int i = 5;
long num = 3L;
short sum = (short) (b + i + num);
10. 10
Floating-point types are:
float (±1.5 × 10−45 to ±3.4 × 1038)
32-bits, precision of 7 digits
double (±5.0 × 10−324 to ±1.7 × 10308)
64-bits, precision of 15-16 digits
The default value of floating-point types:
Is 0.0F for the float type
Is 0.0D for the double type
Floating-Point Types
11. 11
Floating-Point Types – Examples
float f = 0.33f;
double d = 1.67;
double sum = f + d;
float fSum = f + d; // This will not compile
double infinity = 3.14 / 0;
System.out.println(f); // 0.33
System.out.println(d); // 1.67
System.out.println(sum); // 2.000000013113022
System.out.println(infinity); // Infinity
12. 12
The floating-point arithmetic sometime works incorrectly
Don't use float and double for financial calculations!
In Java use the BigDecimal class for financial calculations:
BigDecimal
import java.math.BigDecimal;
…
BigDecimal bigF = new BigDecimal("0.33");
BigDecimal bigD = new BigDecimal("1.67");
BigDecimal bigSum = bigF.add(bigD);
System.out.println(bigSum); // 2.00
16. 16
The String data type:
Declared by the String class
Represents a sequence of characters
Has a default value null (no value)
Strings are enclosed in quotes:
Strings can be concatenated
Using the + operator
The String Data Type
String s = "Hello, Java";
17. 17
Concatenating the names of a person to obtain the full name:
We can concatenate strings and numbers as well:
Saying Hello – Example
String firstName = "Ivan";
String lastName = "Ivanov";
System.out.println("Hello, " + firstName);
String fullName = firstName + " " + lastName;
System.out.println("Your full name is: " + fullName);
int age = 21;
System.out.println("Hello, I am " + age + " years old");
19. 19
The Object type:
Is declared by the java.lang.Object class
Is the base type of all other types
Can hold values of any type
The Object Type
object dataContainer = 5;
System.out.print("The value of dataContainer is: ");
System.out.println(dataContainer);
dataContainer = "Five";
System.out.print("The value of dataContainer is: ");
System.out.println(dataContainer);
22. 22
When declaring a variable we:
Specify its type
Specify its name (called identifier)
May give it an initial value
The syntax is the following:
Example:
Declaring Variables
<data_type> <identifier> [= <initialization>];
int height = 200;
23. 23
Identifiers may consist of:
Letters (Unicode)
Digits [0-9]
Underscore "_"
Examples: count, firstName, Page, брояч, 计数器
Identifiers
Can begin only with a letter or an underscore
Cannot be a Java keyword (like int or class)
Identifiers
24. 24
Literals are the representations of values in the source code
Literals in Java
int dec = 5; // decimal value 5
int hex = 0xFE; // hexadecimal value FE -> 254
int bin = 0b11001; // binary value 11001 -> 25
int bigNum = 1_250_000; // decimal value 1250000
long num = 1234567890123456789L;
long hexNum = 0x7FFF_FFFF_FFFF_FFFFL;
boolean bool = true;
float floatNum = 1.25e+7f; // 12500000
double doubleNum = 6.02e+23; // 602000000000000000000000
char newLine = 'n'; // Character <new line>
char unicodeChar = 'u00F1'; // Character: ñ
long fourBytes = 0b11010010_01101001_10010100_10010010; // -764832622
String str = "Hello,nI'm Java.";
25. 25
Each primitive type in Java has a corresponding wrapper:
int java.lang.Integer
double java.lang.Double
boolean java.lang.Boolean
Primitive wrappers can have a value or be null (no value)
Nullable Types: Integer, Long, Boolean, …
Integer i = 5; // Integer value: 5
i = i + 1; // Integer value: 6
i = null; // No value (null)
i = i + 1; // NullPointerException
27. 27
Operator is an operation performed over data at runtime
Takes one or more arguments (operands)
Produces a new value
Example of operators:
Operators have precedence
Precedence defines which will be evaluated first
Expressions are sequences of operators and operands that are
evaluated to a single value, e.g. (a + b) / 2
What is an Operator?
a = b + c;
Operator "+"
Operator "="
31. 31
Expressions are sequences of operators, literals and variables
that are evaluated to some value (formulas)
Examples:
Expressions
int r = (150-20) / 2 + 5; // r=70
// Expression for calculating a circle area
double surface = Math.PI * r * r;
// Expression for calculating a circle perimeter
double perimeter = 2 * Math.PI * r;
32. 32
Operators and Expressions – Examples
int x = 5, y = 2;
int div = x / y; // 2 (integral division)
float divFloat = (float)x / y; // 2.5 (floating-point division)
long num = 567_972_874; // 567972874
long mid3Digits = (num / 1000) % 1000; // 972
int z = x++; // z = x = 5; x = x + 1 = 6
boolean t = true;
boolean f = false;
boolean or = t || f;
boolean and = t && f;
boolean not = !t;
39. 39
The java.util.Scanner class reads strings and numbers
The numbers can be separated by any sequence of whitespace
characters (e.g. spaces, tabs, new lines, …)
Exception is thrown when non-number characters are entered
Reading from the Console
import java.util.Scanner;
…
Scanner input = new Scanner(System.in);
int firstNum = input.nextInt();
int secondNum = input.nextInt();
3
-5
Sample Inputs
3 -5
40. 40
A more complex example:
Read two words from the first line
Integer and two doubles from the second line
A string from the third line
Reading from the Console (2)
Scanner input = new Scanner(System.in);
String firstWord = input.next("w+");
String secondWord = input.next("w+");
int numInt = input.nextInt();
double numDouble1 = input.nextDouble();
double numDouble2 = input.nextDouble();
input.nextLine(); // Skip to the line end
String str = input.nextLine();
41. 41
Never open more than one Scanner for the same source!
Scanner: Typical Incorrect Usage
int firstInt = readInt();
String secondLine = readLine();
private static int readInt() {
Scanner input = new Scanner(System.in);
return input.nextInt();
}
private static String readLine() {
Scanner input = new Scanner(System.in);
return input.nextLine();
}
Don't open a new Scanner, pass
existing Scanner as parameter!
Don't open a
new Scanner!
43. 43
Using System.out.print() and System.out.println():
Printing to the Console
String name = "SoftUni";
String location = "Sofia";
double age = 0.5;
System.out.print(name);
System.out.println(" is " + age +
" years old organization located in " + location + ".");
// Output:
// SoftUni is 0.5 years old organization located in Sofia.
44. 44
Formatted Printing
Java supports formatted printing by System.out.printf()
%s – prints a string argument
%f – prints a floating-point argument
%.2f – prints a floating-point argument with 2 digits precision
String name = "SoftUni";
String location = "Sofia";
double age = 0.5;
System.out.printf(
"%s is %.2f years old organization located in %s.",
name, age, location);
45. 45
Formatted Printing (2)
%td / %tm / %tY – prints day / month / year from a date
%1$f – prints the first argument as floating-point number
%2$d – prints the second argument as integer number
System.out.printf(
"Today is %1$td.%1$tm.%1$tYn",
LocalDate.now());
// Today is 10.05.2014
System.out.printf("%1$d + %1$d = %2$dn", 2, 4);
// 2 + 2 = 4
Learn more at http://docs.oracle.com/javase/8/docs/api/java/util/Formatter.html
48. 48
Locales in Java define the country and language specific
formatting rules
Reading / printing to the console is locale-dependent
The Bulgarian locale uses "," as decimal separator, e.g. 1,25
The United States locale uses "." as decimal separator, e.g. 1.25
Changing the System locale (for the entire VM)
Locale
Locale.setDefault(Locale.ROOT); // Language-neutral locale
Locale.setDefault(new Locale("BG", "BG")); // Bulgarian
Locale.setDefault(Locale.US); // United States
49. 49
Locale-Specific Input and Output
int age = 0.5;
Locale.setDefault(Locale.ROOT);
System.out.printf("%fn", age); // 0.500000
System.out.println(age); // 0.5
Scanner inputRoot = new Scanner(System.in);
double d = inputRoot.nextDouble(); // Expects 1.25
Locale.setDefault(new Locale("BG", "BG"));
System.out.printf("%fn", age); // 0,500000
System.out.println(age); // 0.5
Scanner inputBG = new Scanner(System.in);
d = inputBG.nextDouble(); // Expects 1,25
52. 52
Java implements the classical if / if-else statements:
Conditional Statements: if-else
Scanner scanner = new Scanner(System.in);
int number = Integer.parseInt(scanner.nextLine());
if (number % 2 == 0) {
System.out.println("This number is even.");
}
else {
System.out.println("This number is odd.");
}
57. 57
Java supports limited set of primitive
data types: byte, short, int, long,
float, double, boolean, object
Java supports the classical operators,
expressions and statements
Like in C#, C++, JavaScript, PHP, …
Scanner and System.out.printf()
provide formatted input / output
Java supports the classical if-else and switch-case
Summary
59. 59
This course (slides, examples, demos, videos, homework, etc.)
is licensed under the "Creative Commons Attribution-
NonCommercial-ShareAlike 4.0 International" license
Attribution: this work may contain portions from
"Fundamentals of Computer Programming with Java" book by Svetlin Nakov & Co. under CC-BY-SA license
"C# Basics" course by Software University under CC-BY-NC-SA license
License
60. Free Trainings @ Software University
Software University Foundation – softuni.org
Software University – High-Quality Education,
Profession and Job for Software Developers
softuni.bg
Software University @ Facebook
facebook.com/SoftwareUniversity
Software University @ YouTube
youtube.com/SoftwareUniversity
Software University Forums – forum.softuni.bg
Editor's Notes
(c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
(c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
(c) 2007 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*