abstract class "ClassA" as ClassA {
{abstract}methodA();
}
class "SubClassA1" as SubClassA1 {
methodA();
}
class "SubClassA2" as SubClassA2 {
This file contains hidden or 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.*; | |
| public class Main { | |
| public static void main(String[] args) throws Exception { | |
| ArrayList<String> list = new ArrayList<>(); | |
| list.add("A"); | |
| list.add("B"); | |
| list.add("C"); | |
| for (String str : list) { | |
| if ("B".equals(str)) { |
This file contains hidden or 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.*; | |
| public class Main { | |
| public static void main(String[] args) throws Exception { | |
| StringBuilder sb = new StringBuilder("abcde"); | |
| System.out.println(sb.capacity()); // 21: StringBuilder takes 16 bytes as buffer by default | |
| } | |
| } |
This file contains hidden or 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
| # -*- coding:utf-8 -*- | |
| import json, config, time, MeCab | |
| from requests_oauthlib import OAuth1Session | |
| from jinja2 import Template | |
| CK = config.CONSUMER_KEY | |
| CS = config.CONSUMER_SECRET | |
| AT = config.ACCESS_TOKEN | |
| ATS = config.ACCESS_TOKEN_SECRET | |
| twitter = OAuth1Session(CK, CS, AT, ATS) |
This file contains hidden or 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
| fun isUniqueChars(str: String): Boolean { | |
| if (str.length > 256) return false | |
| var checker: Int = 0 | |
| for (idx in 0..(str.length-1)) { | |
| val value: Int = str[idx] - 'a' | |
| if ((checker and (1 shl value)) > 0) { | |
| return false | |
| } | |
| checker = checker or (1 shl value) |
rules <<<
# Compute a rate per task and per ‘code’ label
{var=task:http_responses:rate10m,job=webserver} =
rate by code({var=http_responses,job=webserver}[10m]);
# Compute a cluster level response rate per ‘code’ label
{var=dc:http_responses:rate10m,job=webserver} =
sum without instance({var=task:http_responses:rate10m,job=webserver});
This file contains hidden or 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.Calendar | |
| import TimeInterval.* | |
| // 前提となるクラス群 | |
| enum class TimeInterval { DAY, WEEK, YEAR } | |
| data class MyDate(val year: Int, val month: Int, val dayOfMonth: Int) | |
| // RepeatedTimeInterval は TimeInterval と Int の値をプロパティとして持つ | |
| // TimeInterval (すなわちDAY or WEEK or YEAR) が何回分 (Int) か、というデータ構造 | |
| class RepeatedTimeInterval(val timeInterval: TimeInterval, val number: Int) |
This file contains hidden or 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
| data class MyValue(val value: Int) { | |
| operator fun plus(other: MyValue): MyValue { | |
| return MyValue(value + other.value) | |
| } | |
| } | |
| public fun main(args: Array<String>) { | |
| val a = MyValue(1) | |
| val b = MyValue(2) | |
| println(a + b) // MyValue(value=3) |
This file contains hidden or 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
| val arrayList = arrayListOf(1, 5, 2) | |
| Collections.sort(arrayList, { x, y -> y - x }) |
This file contains hidden or 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
| val arrayList = arrayListOf(1, 5, 2) | |
| Collections.sort(arrayList, object : Comparator<Int> { | |
| override fun compare(o1: Int, o2: Int) = o2 - o1 | |
| }) |