Skip to content

Instantly share code, notes, and snippets.

public class Main {
public static void main(String[] args) {
String str1 = "aa";
String str2 = new String("aa"); // newすると別インスタンスになる
System.out.println(str1 == str2); // 同一インスタンスではないため、false
System.out.println(str1.equals(str2)); // 同値のため、true
}
}
public class Main {
public static void main(String[] args) {
int[] arr = {};
System.out.println(arr); // [I@15db9742 みたいなのが出力される
}
}
public class Main1 {
public static void main(String[] args) {
String a = null;
a += "";
System.out.println(a instanceof String); // true
System.out.println(a.equals("null")); // true
}
}
public class Main {
public static void main(String[] args) {
main(1, 1); // ソッド main(int, double) は型 Main1 であいまいです
}
public static void main(int i, double j) {
}
public static void main(double i, int j) {
}
public class Main {
public static void main(String[] args) {
main(1, 1);
}
public static void main(int i, double j) { // この場合、コンパイルエラーとならない
System.out.println("このメソッドが呼ばれる");
}
public static void main(double i, double j) {
}
import java.util.ArrayList;
import java.util.List;
public class Main {
public static void main(String[] args) {
@SuppressWarnings("serial")
List<String> list = new ArrayList<String>() {
{
get(2); // IndexOutOfBoundsExceptionが発生する
add("test1");
Signature expired: 20200219T105852Z is now earlier than 20200219T110350Z (20200219T110850Z - 5 min.)
const obj = {
name: 'yamada',
age: 17
};
const handler = {
set: function(target, prop, value) {
console.log(value)
target[prop] = value.toUpperCase()
},
class Data {
constructor() {}
_update() {
// 処理
}
_insert() {
// 処理
}
}
const handlebars = require('handlebars')
const sentence = 'hello, {{name}}. \n{{#kids}}my name is {{name}} {{/kids}} '
const template = handlebars.compile(sentence)
const param = {
  name: 'takahashi',
  kids: [{ sun: 'kodomo a' }, { sun: 'kodomo b' }]
}
const kekka = template(param)
console.log(kekka)