Introduction to Programming : Java & SpringBoot
  • Table of Contents
  • Introduction to Programming
  • Algorithms and logic
  • Data types and variables
  • Input and output
  • Conditional Statements
  • Loops
  • Functions
  • Arrays and strings
  • Pointers and references
  • Introduction to Object-Oriented Programming (OOP)
    • Demonstrate OOPS Concept
  • File handling
  • Introduction to Spring Boot
  • Core Concepts and Dependency Injection
  • Building Web Applications with Spring Boot
  • Spring MVC and Web Development
  • Database Integration with Spring Data
  • Building RESTful APIs with Spring Boot
  • Securing Spring Boot Applications with Spring Security
  • Advanced Topics in Spring Boot
  • Testing and Deployment
  • Real-world Projects
Powered by GitBook
On this page
  • Understanding data types
  • Declaring and initializing variables
  • Basic arithmetic operations

Data types and variables

Understanding data types

In programming, data types are used to classify different types of data. Here are some common data types:

  • Integer: int age = 25;

  • Floating-point: double pi = 3.14;

  • Boolean: boolean isTrue = true;

  • Character: char letter = 'a';

  • String: String name = "Alice";

Declaring and initializing variables

Variables are used to store data in a program. Here's an example of how to declare and initialize variables in Java:

// Declare and initialize an integer variable
int age = 25;

// Declare and initialize a double variable
double pi = 3.14;

// Declare and initialize a boolean variable
boolean isTrue = true;

// Declare and initialize a character variable
char letter = 'a';

// Declare and initialize a string variable
String name = "Alice";

Basic arithmetic operations

Arithmetic operations are used to perform mathematical calculations in a program. Here are some examples

// Addition
int sum = 2 + 3; // sum = 5

// Subtraction
int difference = 5 - 2; // difference = 3

// Multiplication
int product = 2 * 3; // product = 6

// Division
double quotient = 10.0 / 3.0; // quotient = 3.3333333333333335

// Modulus (remainder)
int remainder = 10 % 3; // remainder = 1

In the above examples, int and double are data types used to represent integer and floating-point numbers, respectively. The arithmetic operators (+, -, *, /, and %) are used to perform addition, subtraction, multiplication, division, and modulus (remainder) operations, respectively.

PreviousAlgorithms and logicNextInput and output

Last updated 2 years ago