Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ npm-debug.log
*.DS_Store
._*

### Nosso exemplos ###
arquivo*.txt
### Examples ###
file*.txt

### Eclipse ###
.settings/
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sudo: required

env:
global:
secure: eXGVND48r4WyUCELydGxJ5NZURQ5iSaMYT6sLyPAdsjoio5NO+/eF17Fw61YqljrSgy+SuYTtHSeVLET4VOVMry2AH2474UD4DDAZ0Fo21s/u/+wQzIW7szO+gzg+PB/22zM67Yx+9ICo+xm10juHwJRyse9s5EFCgL40LtHPWXc5iTbSJtQFbc3YqPMmrvZZEeGYKAEX6uaqeoSi5PJdDrZfMAcienrbXMx9ASW1LlaJXEr3GKQLHxdfeiEsmVpppeYbfVSRcNRGIgFHS397D2eTVBbsTnxx72dqkR6eYC9z0sifai6baTPx34K3Us1lTx9/bR2DKYohNhea7jinYNSuJB2Lyrf3u4qfJPVLlnSgT+fJYPkmmjDuRepRUK6Kvs4M69YA7FdOhSKHpZlKUtIGjRVFe4CTvkoPAJt+lSaifVKWBD6Q18NqgCkCgijIq3Hn8tjtbWHe256fqZYjio4HBHwfifWG5oxK9ZTKxc9Z+wv2mASHhnmjWpHCtFvib8HMtIizqEVOndg58vMFXJNX1sisZxIV8+I7LSgHU7OBfi2A2Ik5Zeuo46Q7/V+2xl/nOOpC6M7Bgbe+c8gFc8PyJA/3w9+m6xUmRuE5F14D4ItXZvK1lR70oBTlFb0fXNQrEejsKAerXRw1ThbmaFZqcw7ppPQrOM+ZvFcQf0=
secure: UQEVLPeTl6NG7X2y3mdXKEOtchx/uPNNwWOckOAaKfFNIG3MMqfDMnBYGrcj38303zwbqYxjg/2ptwpTeA+eW1TWe1N+I1Y/BX6jA0bUKZgS2PvQXN8SHehDV33pWkSkhxhAi3pp/T3cvVugse2MMWtlRCZ9WizY0jn1viU40G3VQJYi4cNe+QwdxEvG7/GlWW11i9D8ev4nhTKEwYUGQ/KZHjCZwWzVjVesvV7mfcvjZWN4OrMYMH76hjIqA6WIa2pVtIgLp1ZF6g13AYQPlqzBTsItssukQfh/1fzrdGD9v/fbH60N6NDqpJmqVfDnCHOuioS8ZNPo9GZ62nDeTPa5EWETwLxqcbJWL4xWZFvDHSEUL5ZFLfEXZAANw2jPojYZU71mqRSGeLE+ZVh2sb11t4oOis0do7MR8G9/3U7vcqpoigslSaECtXN2G3lA4gAJkKzbkvfnQtseDF6LTclG29mGmA8g6uXNN9kBCK5alkhrrerad1otDfkp/09mwWNGzjSlBYGhrbHZiHVNnVlHr0dMbOc33xxOzqSeFNZsUYnUbGt01pVQzIgzMp5cErEHdxMmwvLoePNcaT2iy5kseJOkKlheDF6Lmbo/yoCta7MCIi0Fdrz7AYL+LnYEW8cHKx5vnu7R3/gkDjGdCIG0WRQ+HZPDD19maq6sem0=

jobs:
include:
Expand Down
2 changes: 1 addition & 1 deletion C-references.asc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[[C-references]]
[appendix]
== Referências
== References

include::README.asc[lines=34..-1]
2 changes: 1 addition & 1 deletion LICENSE.asc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 Rinaldo Pitzer Jr. e Rodrigo Moutinho
Copyright (c) 2019 Rinaldo Pitzer Jr. and Rodrigo Moutinho

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
52 changes: 26 additions & 26 deletions README.asc
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
= Guia Prático para Certificação: Atualize sua certificação Java 6 para Java 8
= Practical Guide to Certification: Update your certification from Java 6 to Java 8

image:https://img.shields.io/travis/com/duke-certification/java6-to-java8.svg[Travis (.com), link=https://travis-ci.com/duke-certification/java6-to-java8] image:https://img.shields.io/github/release/duke-certification/java6-to-java8.svg[GitHub release] image:https://img.shields.io/github/release-date/duke-certification/java6-to-java8.svg[GitHub Release Date] image:https://img.shields.io/github/downloads/duke-certification/java6-to-java8/total.svg[GitHub All Releases] image:https://img.shields.io/github/issues/duke-certification/java6-to-java8.svg[GitHub issues] image:https://img.shields.io/github/license/duke-certification/java6-to-java8.svg[GitHub License]
image:https://img.shields.io/travis/com/duke-certification/java6-to-java8-en.svg[Travis (.com), link=https://travis-ci.com/duke-certification/java6-to-java8-en] image:https://img.shields.io/github/release/duke-certification/java6-to-java8-en.svg[GitHub release] image:https://img.shields.io/github/release-date/duke-certification/java6-to-java8-en.svg[GitHub Release Date] image:https://img.shields.io/github/downloads/duke-certification/java6-to-java8-en/total.svg[GitHub All Releases] image:https://img.shields.io/github/issues/duke-certification/java6-to-java8-en.svg[GitHub issues] image:https://img.shields.io/github/license/duke-certification/java6-to-java8-en.svg[GitHub License]

Este projeto serve como material de apoio na realização do exame *https://education.oracle.com/upgrade-to-java-se-8-ocp/pexam_1Z0-813[1Z0-813]* que atualiza qualquer profissional com certificação Java 6 ou inferior, para a versão 8. No momento desta documentação, o _voucher_ do exame custa R$ 597,00 no Brasil.
This project is a support material for the *https://education.oracle.com/upgrade-to-java-se-8-ocp/pexam_1Z0-813[1Z0-813]* exam that updates any certified Java professional from version 6 or lower to version 8.

image::images/ebook-400x400.png[Guia Open Source para Certificação,align="center"]
image::images/ebook-400x400.png[Practical Guide to Certification,align="center"]

Baixe a versão mais recente do ebook https://github.com/duke-certification/java6-to-java8/releases[no link de releases].
Download the eBook latest version on the https://github.com/duke-certification/java6-to-java8-en/releases[releases' page].

== Gerando o Livro
Para gerar cada arquivo do livro (HTML, Epub, Mobi e PDF), utilize a https://github.com/asciidoctor/docker-asciidoctor[imagem oficial do asciidoctor] para não precisar instalar nada em sua máquina, exceto o https://docker.com[Docker].
== Generating the Book
To generate each file in the book (HTML, Epub, Mobi, and PDF), use the https://github.com/asciidoctor/docker-asciidoctor[official asciidoctor image], so you don't have to install anything except https://docker.com[Docker].

Execute este comando a partir do diretório raiz deste projeto:
Run the following command from the root directory of this project:

[source,shell]
.Utilizando Docker Compose
.Using Docker Compose
----
docker-compose run --rm ebook
----

[source,shell]
.Utilizando Docker
.Using Docker
----
# linux / unix
docker run --rm -v $(pwd):/documents/ asciidoctor/docker-asciidoctor scripts/docker-startup.sh

# others (substituir <caminho> pelo diretório completo deste projeto)
docker run --rm -v <caminho>:/documents/ asciidoctor/docker-asciidoctor scripts/docker-startup.sh
# others (change <path> with the full path of this project)
docker run --rm -v <path>:/documents/ asciidoctor/docker-asciidoctor scripts/docker-startup.sh
----

== Referências
== References

Em todas sessões do livro são feitas referências diretas as fontes de inspiração ou argumentação base para a criação deste conteúdo. A seguir o resumo das principais e de outras referências que também fizeram parte dessa jornada de aprendizado.
Direct references are made in every session of the book for the inspiration sources or base resources used during the creation of this content. The following is a summary of the main resources and other references that were also part of this learning journey.

Para criação da estrutura do projeto deste livro foi utilizado como base o projeto https://github.com/rcmoutinho/ebook-with-asciidoctor[ebook-with-asciidoctor].
The project structure of this book is based on the https://github.com/rcmoutinho/ebook-with-asciidoctor[ebook-with-asciidoctor] project.

NOTE: Boa parte das fontes estão em inglês *(en-US)*, mas algumas também podem ser encontradas em português *(pt-BR)*.
NOTE: Most of the sources are in English *(en-US)*, but some can also be found in Portuguese *(pt-BR)*.

* *(en-US)* Excelente livro que mostra o passo-a-passo para tirar a certificação completa do Java 8 ou atualizar para a versão 8, objetivo deste livro.
* *(en-US)* An excellent book that shows you the step-by-step guide to complete Java 8 certification or upgrade to version 8, the purpose of this book.
+
Boyarsky, Jeanne; Selikoff, Scott. OCP: Oracle Certified Professional Java SE 8 Programmer II Study Guide: Exam 1Z0-809 (English Edition) 1st Edition. Wiley. Edição do Kindle.
+
https://www.amazon.com.br/dp/B0191U2H8C[Link na loja Amazon Brasil].
https://www.amazon.com/dp/B0191U2H8C[Amazon.com].

* *(en-US)* Blog do Eugen (Baeldung) com dezenas de artigos focados em Java, entre outros assuntos.
* *(en-US)* Eugen's (Baeldung) blog with dozens of articles focused on Java, among other topics.
+
https://www.baeldung.com/category/java/

* *(en-US)* Tutoriais da própria Oracle com explicações detalhadas da linguagem Java.
* *(en-US)* Oracle's own tutorials with detailed explanations of the Java language.
+
https://docs.oracle.com/javase/tutorial/java/

* *(en-US)* Documentação oficial do Java.
* *(en-US)* Oficial Java documentation.
+
https://docs.oracle.com/javase/8/docs/

* *(pt-BR)* Curso da Alura, que apesar de focar no Java 7 (ao menos no momento da escrita desse texto), mostra como não cair em pegadinhas na prova. Principalmente em relação à situações que exigem pensar como um compilador e apontar a falta de um `;`. São mais de 80 horas de conteúdo. Vale muito a pena para quem quer ir a fundo de cada detalhe da linguagem (pelo menos até a versão 7).
* *(pt-BR)* Alura's course, which despite focusing on Java 7 (at least at the time of writing this text), shows how not to fall on traps on the test. Especially in situations that require thinking like a compiler and pointing out the lack of a `;`. More than 80 hours of content. It is worth it for those who want to go deep into every detail of the Java language (at least until version 7).
+
https://www.alura.com.br/formacao-certificacao-java

=== Material Complementar
=== Complementary Material

* *(pt-BR)* Canal do YouTube https://www.youtube.com/channel/UCyRDiqqSkqGvTE_wIB1nN1w[RinaldoDev] com vídeos explicativos de diversos conceitos da linguagem Java.
* *(pt-BR)* https://www.youtube.com/channel/UCyRDiqqSkqGvTE_wIB1nN1w[RinaldoDev] YouTube channel with explanatory videos of various Java language concepts.

* *(en-US)* https://www.youtube.com/playlist?list=PL3py5YSIGvPMgKXOVqnYn9nBoT_zvsvsi[_Java Challengers_], uma playlist no Youtube do canal do https://twitter.com/RafaDelNero[Rafael Del Nero] que explica desafios de Java para ensinar conceitos importantes da linguagem.
* *(en-US)* https://www.youtube.com/playlist?list=PL3py5YSIGvPMgKXOVqnYn9nBoT_zvsvsi[_Java Challengers_], a Youtube playlist from https://twitter.com/RafaDelNero[Rafael Del Nero's] channel that explains Java challenges to teach essential language concepts.

* *(en-US)* https://devgym.oracle.com/pls/apex/dg/competition/java[Oracle Dev Gym], desafios online e gratuitos para testar suas habilidades de Java.
* *(en-US)* https://devgym.oracle.com/pls/apex/dg/competition/java[Oracle Dev Gym], free online challenges to test your Java skills.
2 changes: 1 addition & 1 deletion book/01-getting-started/sections/01-introduction.asc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
=== Introdução
=== Introduction

include::../../../README.asc[lines=5..6]
6 changes: 3 additions & 3 deletions book/01-getting-started/sections/02-objectives.asc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
=== Objetivos
=== Objectives

Como guia para criação deste livro foi utilizado todos os objetivos citados na seção _"Review Exam Topics"_, de acordo com o https://education.oracle.com/upgrade-to-java-se-8-ocp/pexam_1Z0-813[site da certificação].
As a guide for the creation of this book, we used all the objectives mentioned in the _"Review Exam Topics"_ section, according to the https://education.oracle.com/upgrade-to-java-se-8-ocp/pexam_1Z0-813[certification website].

A missão deste livro é criar o maior número de exemplos práticos possíveis para ajudar você a colocar a mão na massa. Quanto maior for seu contato com os códigos da versão 8 do Java, mais confiante estará na hora do exame, e também para lidar com projetos em Java 8 no mercado de trabalho.
The mission of this book is to create as many practical examples as possible to help you get your hands on coding. The greater your contact with Java version 8 code, the more confident you will be at exam time, as well as dealing with Java 8 projects in the job market.
Original file line number Diff line number Diff line change
@@ -1,137 +1,135 @@
:java-package: src/org/j6toj8/languageenhancements
:section-java-package: ../../../{java-package}

=== Objetos Strings
=== String objects

.Objetivo
.Objective
----
Develop code that uses String objects in the switch statement, binary literals, and numeric literals, including underscores in literals.
-
Desenvolver código que utilize objetos String em instruções Switch, binários literais, e numéricos literais, incluindo underscore (_) em literais.
----

==== String em instruções Switch
==== String in the switch statement

É esperado que o candidato saiba compreender e analisar o uso de Strings em instruções `switch`, como no seguinte exemplo.
The candidate is expected to understand and analyze the use of Strings in `switch` statements, as in the following example.

[source,java,indent=0]
.{java-package}/stringinswitch/StringInSwitch_Complete.java
----
include::{section-java-package}/stringinswitch/StringInSwitch_Complete.java[tag=code]
----

Apesar da certificação ter foco nas atualizações trazidas pelo Java 7 e 8, é esperado que o candidato entenda também conceitos de versões anteriores do Java. Por isso, serão apresentadas algumas regras que talvez você já conheça sobre `switch`, mas utilizando `String` no `switch`.
Although certification focuses on updates brought by Java 7 and 8, the candidate is expected to understand concepts from previous versions of Java as well. Therefore, some rules you may already know about `switch` will be presented but using `String` on the `switch`.

. Todo `case` deve ser único, não pode se repetir.
. Every `case` must be unique, cannot be repeated.

. O `default` pode aparecer em qualquer posição no `switch`.
. The `default` can appear anywhere on the `switch`.
+
.{java-package}/stringinswitch/StringInSwitch_Default.java
[source,java,indent=0]
----
include::{section-java-package}/stringinswitch/StringInSwitch_Default.java[tag=code]
----

. Tipos suportados em `switch`.
* int e Integer
* byte e Byte
* short e Short
* char e Character
. Supported types in `switch`.
* int and Integer
* byte and Byte
* short and Short
* char and Character
* String
* valores de Enums
* Enums values

. Tipos não suportados em `switch`.
. Types not supported in `switch`.
+
.{java-package}/stringinswitch/StringInSwitch_Type.java
[source,java,indent=0]
----
include::{section-java-package}/stringinswitch/StringInSwitch_Type.java[tag=code]
----

. A execução se inicia em um `case` e somente para ao encontrar um `break`.
. Execution starts in a `case` and only stops when it encounters a `break`.
+
.{java-package}/stringinswitch/StringInSwitch_Break.java
[source,java,indent=0]
----
include::{section-java-package}/stringinswitch/StringInSwitch_Break.java[tag=code]
----
+
.saída no console
.console output
[source,console]
----
Janeiro
Não é um mês
Fevereiro
January
Not a month
February
----
+
Nesse caso a execução inicia no `case "jan"`, passar pelo `default` e pelo `case "fev"` até parar no `break`, por isso as 3 strings aparecem no console.
In this case, execution starts in `case "jan "`, goes through `default` and `case "Feb"` until it stops at `break`. So the 3 strings will appear in the console.

. Um `switch` vazio é válido, mesmo que não tenha utilidade.
. An empty `switch` is valid even if it has no use.
+
.{java-package}/stringinswitch/StringInSwitch_Empty.java
[source,java,indent=0]
----
include::{section-java-package}/stringinswitch/StringInSwitch_Empty.java[tag=code]
----

. Todos os valores de `case` precisam ser constantes, ou seja, variáveis finais em tempo de compilação. Se o valor do `case` puder mudar em tempo de execução, o código não compila.
. All `case` values must be constant, i.e., final variables at compile time. If the value of `case` can change at runtime, the code does not compile.
+
.{java-package}/stringinswitch/StringInSwitch_ConstantOnly.java
[source,java,indent=0]
----
include::{section-java-package}/stringinswitch/StringInSwitch_ConstantOnly.java[tag=code]
----

Pronto, essas são as regras de `switch`. Você provavelmente já conheçe algumas referentes à versões anteriores do Java, mas agora você as viu em `switch` que utilizam Strings. Isso não era possível antes do Java 7.
These are the switch rules. You probably already know some about previous versions of Java, but now you have seen them in `switch` that use Strings. This was not possible before Java 7.

==== Literais Binários e Numéricos, incluindo underscore( _ )
==== Binary and numeric literals, including underscores in literals

É esperado que o candidato saiba compreender e analisar o uso de literais binários e numéricos, como no seguinte exemplo.
The candidate is expected to understand and analyze the use of binary and numeric literals, as in the following example.

[source,java,indent=0]
.{java-package}/literals/Literals_Complete.java
----
include::{section-java-package}/literals/Literals_Complete.java[tag=code]
----

Apesar da certificação ter foco nas atualizações trazidas pelo Java 7 e 8, é esperado que o candidato entenda também conceitos de versões anteriores do Java. Por isso, serão apresentadas algumas regras que talvez você já conheça sobre literais.
Although certification focuses on updates brought by Java 7 and 8, the candidate is expected to understand concepts from previous versions of Java as well. So here are some rules you may already know about literals.

. No Java, _Literal_ é qualquer número escrito diretamente no código, como todos do exemplo acima.
. In Java, _Literal_ is any number written directly in code, like the previous example.

. Por padrão, o Java interpreta literais como `int`. Ou seja, se não houver um sufixo no número para mudar seu tipo, ele é um `int`.
. By default, Java interprets literals as `int`. That is, if there is no suffix in the number to change its type, it is an `int`.
+
.{java-package}/literals/Literals_Suffix.java
[source,java,indent=0]
----
include::{section-java-package}/literals/Literals_Suffix.java[tag=code]
----

. Por padrão, o Java interpreta literais como sendo decimais. Existem prefixos que mudam o sistema numérico do literal.
. By default, Java interprets literals to be decimal. There are prefixes that change the numerical system of the literal.
+
.{java-package}/literals/Literals_Prefix.java
[source,java,indent=0]
----
include::{section-java-package}/literals/Literals_Prefix.java[tag=code]
----

. A partir do Java 7, é possível utilizar underscore (_) para separar visualmente um número. Isso não muda o valor do número, e serve apenas para tornar o código mais legível.
. Starting with Java 7, you can use underscore (_) to visually separate a number. This does not change the value of the number, and only serves to make the code more readable.
+
.{java-package}/literals/Literals_Underscore.java
[source,java,indent=0]
----
include::{section-java-package}/literals/Literals_Underscore.java[tag=code]
----

.Referências
.References
****

.Strings em Switch
* Boyarsky, Jeanne; Selikoff, Scott. OCP: Oracle Certified Professional Java SE 8 Programmer II Study Guide (p. 598). Wiley. Edição do Kindle.
.String in the switch statement
* Boyarsky, Jeanne; Selikoff, Scott. OCP: Oracle Certified Professional Java SE 8 Programmer II Study Guide (p. 598). Wiley. Kindle Edition.
* https://docs.oracle.com/javase/8/docs/technotes/guides/language/strings-switch.html[Strings in switch Statements.] Java Documentation.
* https://dzone.com/articles/new-java-7-feature-string[New Java 7 Feature: String in Switch support.] DZone.

.Literais
* Boyarsky, Jeanne; Selikoff, Scott. OCP: Oracle Certified Professional Java SE 8 Programmer II Study Guide (p. 597). Wiley. Edição do Kindle.
.Literals
* Boyarsky, Jeanne; Selikoff, Scott. OCP: Oracle Certified Professional Java SE 8 Programmer II Study Guide (p. 597). Wiley. Kindle Edition.
* https://pt.wikibooks.org/wiki/Java/Literais[Java/Literais.] Wikibooks.

****
Loading