Skip to content

Commit

Permalink
cppToJava/dataTypes,gettingStarted,javaWorld: tweak text
Browse files Browse the repository at this point in the history
  • Loading branch information
damithc committed Aug 6, 2018
1 parent 2c184d2 commit 8b748b7
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
4 changes: 3 additions & 1 deletion cppToJava/dataTypes/primitiveTypes/text.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ Here are the primitive data types in Java:
* **`float`**: a single-precision 32-bit IEEE 754 floating point. This data type should never be used for precise values, such as currency. For that, you will need to use the [java.math.BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html) class instead.
* **`double`**: a double-precision 64-bit IEEE 754 floating point. For decimal values, this data type is generally the default choice. This data type should never be used for precise values, such as currency.
* **`boolean`**: has only two possible values: `true` and `false`.
* **`char`**: The char data type is a single 16-bit Unicode character. It has a minimum value of '\u0000' (or 0) and a maximum value of '\uffff' (or 65,535 inclusive).
* **`char`**: The char data type is a single 16-bit Unicode character. It has a minimum value of `'\u0000'` (or `0`) and a maximum value of `'\uffff'` (or `65,535` inclusive).


**`String`** (a peek)

{{ different }} Java has a built-in type called `String` to represent strings. While `String` is not a primitive type, they are used as often, if not more. `String` values are demarcated by enclosing in a pair of double quotes. You can use the plus operator to concatenate strings.
E.g.,
```java
String name = "John Doe";
System.out.println("Hello " + name + "!");
```

String is not a primitive type. You’ll learn more about strings in a later section.

Expand Down
9 changes: 5 additions & 4 deletions cppToJava/dataTypes/variables/text.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int i = 100000;
```

You can use any name starting with a letter, underscore, or $ as a variable name but you cannot use Java [keywords](http://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html) as variables names.
You can display the value of a variable using print or println. The following statements declare a variable named firstLine, assign it the value "Hello, again!", and display that value.
You can display the value of a variable using `System.out.print` or `System.out.println` (the latter goes to the next line after printing). To output multiple values on the same line, it’s common to use several print statements followed by println at the end.

```java
int hour = 11;
Expand All @@ -33,16 +33,17 @@ System.out.print("The current time is ");
System.out.print(hour);
System.out.print(":");
System.out.print(minute);
System.out.println(".");
System.out.println("."); //use println here to complete the line
System.out.println("done");

```
{{ icon_output }}

```
The current time is 11:59.
done
```

To output multiple values on the same line, it’s common to use several print statements followed by println at the end.

Use the keyword `final` to indicate that the variable value, once assigned, should not be allowed to change later i.e., act like a ‘constant’. By convention, names for constants are all uppercase, with the underscore character (`_`) between words.

```java
Expand Down
2 changes: 1 addition & 1 deletion cppToJava/gettingStarted/compiling/text.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ To compile the HelloWorld program, open a command console, navigate to the folde

{{ icon_terminal }} `javac HelloWorld.java`

If the compilation is successful, you should see a file `HelloWorld.class`. That file contains the byte code for your program. If the compilation is successful, you will be notified of the <trigger for="pop:compiling-errors">compile-time errors</trigger>.
If the compilation is successful, you should see a file `HelloWorld.class`. That file contains the byte code for your program. If the compilation is unsuccessful, you will be notified of the <trigger for="pop:compiling-errors">compile-time errors</trigger>.

<popover id="pop:compiling-errors" title="Compile-time errors" placement="top">
  <div slot="content">
Expand Down
5 changes: 3 additions & 2 deletions cppToJava/gettingStarted/helloWorld/text.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ int main() {
}
```
This HelloWorld Java program defines one method named main: `public static void main(String[] args)`

`System.out.println` displays results on the screen.


Expand All @@ -61,10 +62,10 @@ A statement is a line of code that performs a basic operation. In the HelloWorld

{{ different }} Some differences:

* Java use the term _method_ instead of _function_. In particular, Java doesn’t have stand-alone functions. Every method should belong to a class. The `main` method work will not work unless it is inside the `HelloWorld` class.
* Java use the term _method_ instead of _function_. In particular, Java doesn’t have stand-alone functions. Every method should belong to a class. The `main` method will not work unless it is inside the `HelloWorld` class.
* A Java class definition does not end with a semicolon, but most Java statements do.
* In _most_ cases (i.e., there are exceptions), the name of the class has to match the name of the file it is in, so this class has to be in a file named `HelloWorld.java`.
* There is no need for the HelloWorld code to have something like `#include <iostream>`. The library files needed by the HelloWorld code is available by default without having to "include" in explicitly.
* There is no need for the HelloWorld code to have something like `#include <iostream>`. The library files needed by the HelloWorld code is available by default without having to "include" them explicitly.
* There is no need to `return 0` at the end of the main method to indicate the execution was successful. It is considered as a successful execution unless an error is signalled specifically.

</div>
Expand Down
4 changes: 2 additions & 2 deletions cppToJava/gettingStarted/installation/text.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

<div id="body">

To _run_ Java programs, you only need to have a recent version of the _Java Runtime Environment (JRE)_ installed in your device.
To _run_ Java programs, you only need to have a recent version of the _Java Runtime Environment (==JRE==)_ installed in your device.

If you want **to _develop_ applications for Java, download and install a recent version of the _Java Development Kit (JDK)_**, which includes the JRE as well as additional resources needed to develop Java applications.
If you want **to _develop_ applications for Java, download and install a recent version of the _Java Development Kit (==JDK==)_**, which includes the JRE as well as additional resources needed to develop Java applications.

</div>

Expand Down
2 changes: 1 addition & 1 deletion cppToJava/javaWorld/how/text.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<div id="body">

**Java is both _compiled_ and _interpreted_.** Instead of translating programs directly into machine language, the Java compiler generates _byte code_. Byte code is _portable_, so it is possible to compile a Java program on one machine, transfer the byte code to another machine, and run the byte code on the other machine. That’s why Java is considered a _platform independent technology_, aka _WORA_ (Write Once Run Anywhere). The interpreter that runs byte code is called a “Java Virtual Machine” (JVM).
**Java is both <tooltip content="generates machine code from source code before executing the program">_compiled_</tooltip> and <tooltip content="the interpreter executes the program directly, one statement at a time">_interpreted_</tooltip>.** Instead of translating programs directly into machine language, the Java compiler generates _byte code_. Byte code is _portable_, so it is possible to compile a Java program on one machine, transfer the byte code to another machine, and run the byte code on the other machine. That’s why Java is considered a _platform independent technology_, aka _WORA_ (Write Once Run Anywhere). The interpreter that runs byte code is called a “Java Virtual Machine” (JVM).

>**Java technology is both a _programming language_ and a _platform_.** The Java programming language is a high-level object-oriented language that has a particular syntax and style. A Java platform is a particular environment in which Java programming language applications run. <small>--[Oracle](https://docs.oracle.com/javaee/6/firstcup/doc/gkhoy.html)</small>
Expand Down

0 comments on commit 8b748b7

Please sign in to comment.