0
0

More than 3 years have passed since last update.

始めて学ぶjava #3 式と演算子

Posted at

式とは?

public class Main {
    public static void main(String[] args) {
        int a;
        int b;
        a = 20;
        b =a+5;
        System.out.println(a);
        System.out.println(b);
    }
}

実行結果

20
25

6行目のようなものを式と呼ぶ。
「a」、「b」、「5」をオペランド、「+」、「*」を演算子と呼ぶ。
複雑な式であっても同じく、すべての式はこの二つで成り立っている。

リテラル

オペラントの中でも「5」や「hello,world」などソースコードに記述してあることをリテラルと呼ぶ。
リテラルは(int)などのデータ型を持っている。

エスケープシーケンス

¥記号とそれに続く一文字で記述する記述方法で特殊な一文字を表す。

表記 意味
¥” 二重引用符記号
¥ ’ 引用符記号
¥¥ 円記号
¥n 改行

演算子

演算子 機能
足し算
引き算
掛け算
割り算
割り算の余り(余剰)
文字列の連結
右辺を左辺に代入
+= 左辺と右辺を加算して左辺に代入(算術演算子の通りある)
++ 値を一つ増やす
ーー 値を一つ減らす
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0