Java and Back Again

A beginners tale….part 1

Robert M Ricci
Mar 14 · 3 min read
Get it java?…no?…yeah

So one of the things I loved the most about getting into software engineering is that most of the people I’ve talked to have been pretty welcoming and helpful. They have been very generous with their time, and their advice. That isn’t to say that everyone has been, but it is definitely the majority. This leads up to today's topic, Java. No, I’m not talking about coffee, although their logo is a coffee cup. I’m talking about the programming language.

I recently was able to have a mock interview of sorts with a local software engineer. He was willing to take time out of his schedule and give me some advice. Turns out I’m pretty good at talking to people, what I mean to say is that I’m fairly personable. Which is nice to know, and eliminates one hurdle to get through. During the conversation, the topic of languages came up, more specifically which ones are widely used in my area. He suggested that I look into .Net or Java. Since I enjoy working on a mac, I decided to go with Java, not to mention I had access to some course materials. I decided to break this up into multiple parts. So in this article, I’m going to go over the very basics. I will talk a little about the history of Java, its current status, and code structure.

Java was created in 1995 by James Gosling while he was working at Sun Microsystems. It is now owned by Oracle, who purchased it in 2009, mainly because a lot of their products were Java-based, and were worried about what would happen if someone else purchased it. They are currently on Java 15, which released in September 2020, but they still offer non-commercial support for Java 8.

Java is an object-oriented language and is similar to C. I think my time with Ruby, it is making it a little easier for me to learn. I seem to be picking it up with some ease. I still only at the beginning and haven't got into anything super complicated, mostly learning the syntax for things I already know about from other languages. One of the main differences I noticed between Java and Ruby specifically is that Java has a lot more typing. You have to declare a lot more about what your code is doing, that is not to say that it is a declarative language. I will give code examples below.

JAVA Code Examples

Every java program must include certain things:

  • A file name with a .java extension.
  • a class that is usually the same as the file name, and followed by curly braces. Everything after the braces are included in the class.
  • The main method also followed by curly braces.

Key Words:

  • public: marks something as accessible by any other class.
  • void: specifies that a method should not have a return value.
  • static: can be accessed without creating an object of a class.
HelloWorld.javapublic class HelloWorld{public void static main(String[] args){
}

Here are examples of four primitive variables and one Object.

  • int: A data type that can store whole numbers from -2147483648 to 2147483647.
  • double: A data type that can store whole numbers from 1.7e−308 to 1.7e+308.
  • boolean: A data type that can only store true and false values.
  • char: A data type that is used to store a single character.
  • String: This is an object that can hold multiple characters within double-quotes.
HelloWorld.javapublic class HelloWorld{   int number = 42;   double decimal = 3.14;   char letter = "a";   boolean truth = true;   String phrase = "May the force be with you";public void static main(String[] args){}

CONCLUSION

That’s going to be it for this article. In the next one, we will go over the state, instances, and a few other topics. I would also like to mention that I write these posts as much for myself, to get the ideas down, as I do for other people. In saying that they can sometimes be fairly basic in their topics. Especially if it’s something I’m revisiting. So keep that in mind as you read. The next parts will have slightly more in-depth.

Geek Culture

Proud to geek out. Follow to join our +1.5M monthly readers.