mirror of
https://github.com/krahets/hello-algo.git
synced 2026-11-02 03:05:24 +08:00
Retranslate the complete Japanese online edition from Chinese (#2008)
* Retranslate the complete Japanese online edition from Chinese * Fit Japanese homepage labels and localize heading permalinks * Point Japanese contribution instructions to the Japanese preview * Replace locale conditionals with multilingual UI tables
This commit is contained in:
@@ -8,7 +8,7 @@ package chapter_stack_and_queue;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/* 配列ベースのスタック */
|
||||
/* 配列で実装したスタック */
|
||||
class ArrayStack {
|
||||
private ArrayList<Integer> stack;
|
||||
|
||||
@@ -17,12 +17,12 @@ class ArrayStack {
|
||||
stack = new ArrayList<>();
|
||||
}
|
||||
|
||||
/* スタックの長さを取得 */
|
||||
/* スタックの長さを取得する */
|
||||
public int size() {
|
||||
return stack.size();
|
||||
}
|
||||
|
||||
/* スタックが空かどうかを判定 */
|
||||
/* スタックが空かどうかを判定する */
|
||||
public boolean isEmpty() {
|
||||
return size() == 0;
|
||||
}
|
||||
@@ -39,7 +39,7 @@ class ArrayStack {
|
||||
return stack.remove(size() - 1);
|
||||
}
|
||||
|
||||
/* スタックトップの要素にアクセス */
|
||||
/* スタックの先頭要素にアクセスする */
|
||||
public int peek() {
|
||||
if (isEmpty())
|
||||
throw new IndexOutOfBoundsException();
|
||||
@@ -54,10 +54,10 @@ class ArrayStack {
|
||||
|
||||
public class array_stack {
|
||||
public static void main(String[] args) {
|
||||
/* スタックを初期化 */
|
||||
/* スタックを初期化する */
|
||||
ArrayStack stack = new ArrayStack();
|
||||
|
||||
/* 要素をプッシュ */
|
||||
/* 要素をプッシュする */
|
||||
stack.push(1);
|
||||
stack.push(3);
|
||||
stack.push(2);
|
||||
@@ -65,20 +65,20 @@ public class array_stack {
|
||||
stack.push(4);
|
||||
System.out.println("スタック stack = " + Arrays.toString(stack.toArray()));
|
||||
|
||||
/* スタックトップの要素にアクセス */
|
||||
/* スタックの先頭要素にアクセスする */
|
||||
int peek = stack.peek();
|
||||
System.out.println("スタックトップ要素 peek = " + peek);
|
||||
System.out.println("スタックの先頭要素 peek = " + peek);
|
||||
|
||||
/* 要素をポップ */
|
||||
/* 要素をポップする */
|
||||
int pop = stack.pop();
|
||||
System.out.println("ポップした要素 pop = " + pop + "、ポップ後の stack = " + Arrays.toString(stack.toArray()));
|
||||
System.out.println("ポップした要素 pop = " + pop + "、ポップ後 stack = " + Arrays.toString(stack.toArray()));
|
||||
|
||||
/* スタックの長さを取得 */
|
||||
/* スタックの長さを取得する */
|
||||
int size = stack.size();
|
||||
System.out.println("スタックの長さ size = " + size);
|
||||
|
||||
/* 空かどうかを判定 */
|
||||
/* 空かどうかを判定する */
|
||||
boolean isEmpty = stack.isEmpty();
|
||||
System.out.println("スタックが空かどうか = " + isEmpty);
|
||||
System.out.println("スタックは空か = " + isEmpty);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user