r/javahelp • • Dec 01 '19

Review my small chapter on Java (Beginners book)

Hello everyone, I'm writing a book designed for people who are looking for a career in Software engineering. One part of the book covers a collection of programming languages that are popular in today's industry. Each chapter covers a language in a very brief (not going into too much detail) format:

  1. Relevant Quote
  2. Language introduction - Talks about how it came into fruition and a brief explanation of what it is and how it gets used.
  3. Code example - Here is provided with a small code example just to give the reader a taste of the language's syntax and features.
  4. Use cases - cover one or more of the following: types of developers that use it, what industries use it, what platforms and project examples.
  5. Did you know - is a dumping ground for some interesting facts about the language.

I wanted to run this chapter past the subreddit Java to see if there is anything you guys would add on any of the sub-sections listed above -- to capture the language in the best way. Or highlight anything that is inaccurate/wrong. Thank you!!

## Java

> "Java is C++ without the guns, clubs and knives."
>
> -- _James Gosling - Creator of Java_

---

### Language introduction

Java is used by 90% of Fortune 500 companies as their server-side language. It's the official and original language for development with the Android platform. From laptops to data centres, game consoles and scientific computers use it. It exists in a lot of places.

Java is an object oriented language like C++ and C#.

### Code example

In the Investment world, a customer can create as many pots as they'd like. So if the back-end engineers create an 'Investment Pot' class, it can be used again and again to model pots of a real customer.

Here is a contrived example of an Investment Pot.

#### ![Script icon](./images/script.png){ width=75px height=75px } InvestmentPot.java

```java
class InvestmentPot {
  private float total;

  public InvestmentPot(float total) {
    this.total = total;
  }

  public void addContribution(float contribution) {
    // add the new contribution to the total cash pot value
    this.total += contribution;
  }

  public String outputTotal() {
    return "Total pot value is " + this.total;
  }
}
```

Above the pot can store the total cash amount that a pot has, and we have exposed a behaviour/method/function that allows people to add more money/make a contribution.

We usually have a main entry-point into the application. The code below will be fired first when running the application.

#### ![Script icon](./images/script.png){ width=75px height=75px } App.java

```java
public class App {
  public static void main(String[] args) {
    float startingAmount = 2000;
    float contribution = 250;
    // We are creating a new object of
    // our InvestmentPot class blueprint
    InvestmentPot myPot = new InvestmentPot(startingAmount);
    // calling the method below
    myPot.addContribution(contribution);

    System.out.print(myPot.outputTotal());
  }
}
```

### Use cases

Java is extremely popular. There are more than 9 million Java developers in the world and the odds of getting a job are quite high. According to indeed.com -- at the time of writing -- Java is the top language for job postings.

- Build Android apps
- Build software tools
- Enterprise applications
- Used by NASA (One application zooms in from outer space and can examine a location on earth)
- Used for self-driving cars
- Math-oriented applications (Scientific processing with visualisers)
- One of the main choices of Academic study for Computer science.

### Did you know

Java was created back in 1995 - meaning it's one of the oldest programming languages in motion.

Java gets downloaded more than a billion times each year.

Java's original name was OAK. The creator James Gosling named it after the oak tree he saw outside his office window.

Google and Oracle had to settle a \$9 billion copyright lawsuit around the use of Java -- a language owned by Oracle. Google had incorporated 11,500 lines of Oracle's code into the Android platform.
0 Upvotes

0 comments sorted by