This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// クラスフィールドとインスタンスフィールドの実験目的なため、コンストラクタやアクセサメソッドなどは用意しない. | |
public class Student { | |
// クラスフィールド | |
private static String schoolName; | |
// インスタンスフィールド | |
private String name; | |
private int age; | |
public static void main(String[] args) { | |
System.out.println("==========Tanaka==========="); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class VolatileSample { | |
private static volatile int count = 0; // メインメモリの変数に対して読み書きする | |
// private static int count = 0; // 各スレッドの対応するキャッシュした変数に対して読み書きする | |
public static void main(String[] args) { | |
new MultiThread1().start(); | |
new MultiThread2().start(); | |
} | |
// Thread-0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.FileInputStream; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
import java.io.ObjectInputStream; | |
import java.io.ObjectOutputStream; | |
import java.io.Serializable; | |
class TransientSample01 { | |
public static void main(String[] args) { | |
final Person3 person = new Person3("Tanaka", 20, "Tokyo", "09012345678"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
public static class Person { | |
public int age; | |
} | |
public static void main(String[] args) { | |
System.out.println("参照型 配列の実験-START"); | |
int[] arrayInt = {10, 20, 30}; // インスタンス生成 | |
foo(arrayInt); | |
System.out.println(arrayInt[0]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package xxx; // TODO 自分のパッケージ名に変更する | |
import androidx.appcompat.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.widget.ArrayAdapter; | |
import android.widget.Spinner; | |
public class MainActivity extends AppCompatActivity { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package xxxx; // TODO パッケージ名は自分の環境に合わせてください | |
import android.annotation.SuppressLint; | |
import android.content.Context; | |
import android.util.AttributeSet; | |
import android.util.Log; | |
import android.view.MotionEvent; | |
import android.view.View; | |
import android.view.ViewTreeObserver; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package xxx; // TODO 環境に合わせて変更してください | |
import android.content.Context; | |
import android.media.AudioAttributes; | |
import android.media.SoundPool; | |
import android.util.Log; | |
import androidx.annotation.NonNull; | |
import androidx.lifecycle.DefaultLifecycleObserver; | |
import androidx.lifecycle.LifecycleOwner; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.xxx.xxx; // TODO change your package name. | |
import android.animation.ObjectAnimator; | |
import android.animation.PropertyValuesHolder; | |
import android.animation.TimeInterpolator; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.view.animation.AccelerateDecelerateInterpolator; | |
import android.view.animation.AccelerateInterpolator; | |
import android.view.animation.AnticipateInterpolator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package xxx; // TODO change your package name. | |
import android.text.Editable; | |
import android.text.TextUtils; | |
import android.text.TextWatcher; | |
import android.view.View; | |
import androidx.annotation.NonNull; | |
import java.util.Arrays; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.InputMismatchException; | |
import java.util.NoSuchElementException; | |
import java.util.Scanner; | |
public class MultiplicationTable { | |
public static void main(String[] args) { | |
System.out.print("数値を入力してください: "); | |
try (final Scanner scan = new Scanner(System.in)) { // try with resource構文で scan.closeの呼び出し忘れを防ぐ. | |
final int tableSize = scan.nextInt(); | |
if (tableSize < 1 || 20 < tableSize) {// 条件に合わなければ、早期リターンする. |
NewerOlder