Home > Java > javaTutorial > Java for Beginners - Introduction: Introduction, Fundamentals and Practice #Cap1

Java for Beginners - Introduction: Introduction, Fundamentals and Practice #Cap1

DDD
Release: 2025-01-11 20:03:51
Original
204 people have browsed it

Java Para Iniciantes - Introdução: Introdução, Fundamentos e Prática #Cap1

  • Important Information from Chapter 1
    • Introduction to Java and its Importance
  • Java Evolution
  • Key Features
  • Why choose Java in 2024?
  • Contributions
  • Bytecode
  • POO
  • Data Types
  • Conversions and Good Language Practices
  • Repeating Blocks and Structures
  • Identifiers
  • Libraries
  • Treating syntax errors
  • My first programs

Important Information from Chapter 1

Created by Sun Microsystems in 1995.

Popularized the "Write Once, Run Anywhere" (WORA) concept.

1. Introduction to Java and its Importance

History and Motivation of Java: The chapter covers the creation of Java, its origins in 1995, and the reasons why it has become such a popular and reliable language, especially in enterprise systems, mobile devices and IoT.

Java is a robust, high-level, object-oriented programming language widely used in the development of enterprise applications, enterprise systems, web, and mobile applications. Developed by Sun Microsystems (now owned by Oracle), it is known for its portability, security, and strong support for multithreading. Java is highly scalable and has a vast ecosystem of libraries, frameworks such as Spring and Hibernate, as well as integration tools such as Maven and Gradle. The language is also used in corporate environments for its efficient processing capabilities and reliability in native execution. Additionally, Java supports different architectures and operating systems, making it a popular choice for developing robust and scalable software.

JAVA EVOLUTION

A summary of the main features from the beginning!

# Java 1.0 (1995) – O Começo ?
- Write Once, Run Anywhere (WORA)
- Suporte a:
  - Applets
  - Multithreading básico

# Java 1.2 (1998) – Java 2 e a Revolução ?
- Swing: Nova biblioteca para GUIs
- Collections Framework: Estruturas como ArrayList e HashMap
- JIT Compiler: Melhor desempenho

# Java 1.4 (2002) – Robustez e Desempenho ?
- Assertions para depuração
- Pacote java.nio: Melhorias no I/O
- Expressões Regulares (java.util.regex)

# Java 5 (2004) – Modernização da Linguagem ?
- Generics: List<String> 
- Enhanced for-loop: for (int i : array)
- Annotations: @Override
- Enums e Varargs
- Concurrent API: Melhor suporte a threads

# Java 6 (2006) – Refinamentos ?️
- Melhor desempenho da JVM
- Compiler API (javax.tools)
- Java Scripting API: Integração com JavaScript

# Java 7 (2011) – Simplificação e Eficiência ⚡
- Try-with-resources: Gerenciamento automático de recursos
- Switch com Strings
- Multi-catch em exceções
- NIO.2: Melhor manipulação de arquivos

# Java 8 (2014) – Programação Funcional ?
- Lambdas: (x) -> x * 2
- Streams API: Processamento declarativo de coleções
- Optional: Lidar com null de forma segura
- API de Data e Hora (java.time)
- Default Methods: Métodos padrão em interfaces

# Java 9 (2017) – Modularização ?
- JPMS: Java Platform Module System
- JShell: REPL para experimentaçã
Copy after login
Copy after login

Key Features:

  • Portability (Write Once, Run Anywhere - WORA).
  • Strong typing and security.
  • Support multithreading and object-oriented programming.

Why choose Java in 2024?

Comparison between Java and Python.
| Feature | Java | Python |
|----------------------|-------------------------- ----|------------------------------|
| Paradigm | Object Oriented | Multiparadigm |
| Syntax Style| Stricter syntax | More flexible syntax |
| Execution Speed | Fast for native execution | Slightly slower than Java running natively |
| Compatibility | Very good, especially for corporate applications | Good for web applications and scripting |
| Community | Large, robust community | Active and broad community |
| Ecosystem | Large ecosystem | Extensive ecosystem with frameworks, libraries and modules |
| Corporate Use | Strongly used in companies | Widely used in data science, machine learning, web development |
| Application Types| Corporate applications, backend, embedded systems | Web, data science, automation, scripting |
| Performance | Better native performance | Better performance for rapid development and prototyping |
| Memory Requirement| Increased memory usage | Lower memory usage |
| Market Entries| Launched in 1995 | Launched in 1991 |
| Choice for Web | Widely used for backend | Popular for web development |
| Ease of Learning| A little more difficult for beginners | Easier for beginners |
| Security | Good, with several security mechanisms | Good, but in web applications it may require extra care |
| Multithreading | Robust support for multithreading | Support for multithreading, but may be less efficient in some cases |

Contributions

  • Introduction of bytecode for portability.
  • Advancement of Object Oriented Programming (OOP) and security.

Bytecode

- Bytecode: intermediate code executed by the JVM.

POO

  • OOP (Object Oriented Programming): a programming paradigm that organizes code around objects.
    • THE four pillars:
      • ABSTRACTION
      • INHERITANCE
      • POLYMORPHISM
      • ENCAPSULATION

Data Types

  • Primitive types like int, double, char.
# Java 1.0 (1995) – O Começo ?
- Write Once, Run Anywhere (WORA)
- Suporte a:
  - Applets
  - Multithreading básico

# Java 1.2 (1998) – Java 2 e a Revolução ?
- Swing: Nova biblioteca para GUIs
- Collections Framework: Estruturas como ArrayList e HashMap
- JIT Compiler: Melhor desempenho

# Java 1.4 (2002) – Robustez e Desempenho ?
- Assertions para depuração
- Pacote java.nio: Melhorias no I/O
- Expressões Regulares (java.util.regex)

# Java 5 (2004) – Modernização da Linguagem ?
- Generics: List<String> 
- Enhanced for-loop: for (int i : array)
- Annotations: @Override
- Enums e Varargs
- Concurrent API: Melhor suporte a threads

# Java 6 (2006) – Refinamentos ?️
- Melhor desempenho da JVM
- Compiler API (javax.tools)
- Java Scripting API: Integração com JavaScript

# Java 7 (2011) – Simplificação e Eficiência ⚡
- Try-with-resources: Gerenciamento automático de recursos
- Switch com Strings
- Multi-catch em exceções
- NIO.2: Melhor manipulação de arquivos

# Java 8 (2014) – Programação Funcional ?
- Lambdas: (x) -> x * 2
- Streams API: Processamento declarativo de coleções
- Optional: Lidar com null de forma segura
- API de Data e Hora (java.time)
- Default Methods: Métodos padrão em interfaces

# Java 9 (2017) – Modularização ?
- JPMS: Java Platform Module System
- JShell: REPL para experimentaçã
Copy after login
Copy after login
  • Specific objects and value ranges.

Conversions and Good Language Practices

  • Implicit or explicit conversions (casting).
  • Clear names and use of comments for readability.

Repeating Blocks and Structures

  • Blocks organize sections with {}; Structures include for, while, do-while.
  • Essentials for condition-based repetitive execution.

Identifiers

  • Name variables, methods and classes.
  • Follow conventions (e.g. camelCase for variables, PascalCase for classes).

Libraries

  • Includes standard libraries like java.util and java.io.
  • Code reuse and complexity reduction.

Treating syntax errors

  • Common mistakes like forgetting; or {}.
  • Error messages help with debugging.
  • Try Catch: is a programming structure that allows the programmer to control the flow of code execution in unforeseen situations

    public class TiposDeDadosExample {
        public static void main(String[] args) {
            int numero = 10;       // Tipo inteiro
            double pi = 3.14159;   // Tipo decimal
            char letra = 'A';      // Tipo caractere
            boolean verdadeiro = true;  // Tipo booleano
    
            System.out.println("Número: " + numero);
            System.out.println("Valor de pi: " + pi);
            System.out.println("Letra: " + letra);
            System.out.println("Valor booleano: " + verdadeiro);
        }
    }
    
    Copy after login

My first programs

  • Basic examples like "Hello, World!" for introduction. > Hello World
try {
int result = 10 / 0;  // Possível erro de execução
} catch (ArithmeticException e) {
    System.out.println("Erro: " + e.getMessage());
}
Copy after login
  • Use of the main method and execution through the terminal.
  • Class Example of an Object in Java
public class OláMundo {
    public static void main(String[] args) {
        System.out.println("Olá, Mundo!");
    }
}
Copy after login

GOOD STUDIES! Enjoy the journey.

Previous Topic

  • JAVA FOR BEGINNERS: General Guidelines and Environment Settings

Next Topic

  • JAVA FOR BEGINNERS: CACP 2

The above is the detailed content of Java for Beginners - Introduction: Introduction, Fundamentals and Practice #Cap1. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template