About Java features


This article is a record of what I understand for those who are studying Java.

From now on, Java functions and description methods will be described in the following list.

・ Variables, types, and type conversion https://qiita.com/pitan109/items/2538b234a2c6e20c037f -Variable scope https://qiita.com/pitan109/items/b30589bc4c2e8169734c ・ Character string operation (in preparation) ・ Array operation (in preparation) ・ Operator (in preparation) ・ Conditional branch (in preparation) ・ Repeat processing (in preparation) ・ Exception handling (in preparation) ・ About class (in preparation) ・ Abstract class (in preparation) ・ Interface (in preparation) ・ Encapsulation (in preparation) ・ About the module (in preparation)

This time, I will list an overview of what you should remember when using Java and a comparison with Ruby because I used Ruby myself.

5/11 update Added common points and advantages and disadvantages of each method 5/12 update Added table of contents

Compiler method

To put it simply, a compiler (compile) is to change all the code into a computer-readable form before executing it. This is adopted in Java. C ++ is also a compiler method. Ruby and python are interpreted methods. The interpreter translates line by line and executes it. Let's see what the difference is.


$ ruby hello.rb

 When you run it in the interpreter, you'll see what's happening in your code.


#### **`$ javac hello.java `**

 Since this example is Java, we will explain it with Javac commands. The compiler enters the commands to compile and produces a computer-aware class file. Now that you have a Hello class in the hello.java file, run it.

```$ java hello```
 This will execute the processing in the class. Keep in mind that you can't run Java without following this procedure.

## Variable type, type conversion
 In Java, you need to statically type variables.
 String str = "character type";
 I am creating a variable called str with a character type (String), but I cannot assign an element of another type such as a numeric type (int) to it.
 In Ruby
 str = "character type"
 Can be described as. After this because there is no association
str = 1
 It is okay to write.

 You can also type convert in Java. It is used when you want to refer to this variable with this type.

 Type conversion is also possible in Ruby, and the idea is the same, except that the description method is basically different.


String str = (String)10;


str = 10.to_s

Details on variable type specification and type conversion in Java can be found here. https://qiita.com/pitan109/items/2538b234a2c6e20c037f

Variable scope

In both Java and Ruby, the range in which variables can be referenced changes depending on where the variables are written and the description method. There are various ways of writing in Java and Ruby, but the idea is the same, and I think that what I learned in Java can be applied to Ruby.

The reference range and description method of variables in Java are described in detail here. https://qiita.com/pitan109/items/b30589bc4c2e8169734c

Common points between Ruby and Java

Since I was using Ruby this time, I will also describe the common parts as a bonus. It's an object-oriented language and you can use interfaces. I won't go into the details of how to write it here, but if you have an object-oriented or interface concept and you are learning one language, The other way of thinking can be used almost as it is, so I think it is recommended to learn one object-oriented language, not limited to Java and Ruby.

At the end

This time, I tried to summarize the main functions of Java while comparing it with Ruby. I also referred to this article. https://codezine.jp/article/detail/2144

Recommended Posts

[Java] About Java 12 features
About Java features
Java features
Java features
[Java] About arrays
Something about java
Where about java
About Java threads
java1.8 new features
[Java] About interface
About Java class
About Java arrays
About java inheritance
About interface, java interface
About List [Java]
About java var
About Java literals
About Java commands
About Java log output
About Java functional interface
About class division (Java)
About [Java] [StreamAPI] allMatch ()
About Java method binding
[Java] About anonymous classes
About method splitting (Java)
About Java Array List
About Java Polymorphism super ()
About inheritance (Java Silver)
About Java String class
About Java access modifiers
About Java lambda expressions
About Java entry points
About Java 10 Docker support
Personal summary about Java
[Java] About enum type
All about Java programming
[Java] Three features of Java
About java abstract class
A note about Java GC
What I researched about Java 8
Java version 8 and later features
About an instance of java
What I researched about Java 6
[Gradle] About Java plug-in tasks
New features from Java7 to Java8
About Java variable declaration statements
What I researched about Java 9
[Java] About try-catch exception handling
About Java class loader types
[Java Silver] About equals method
[Java] About String and StringBuilder
What I researched about Java 7
About =
About Alibaba Java Coding Guidelines
About Java class variables class methods
About Java Packages and imports
About abstract classes in java
[Android / Java] Learned about DataBinding
What I researched about Java 5