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
var ( | |
decoderType = reflect.TypeOf((*Decoder)(nil)).Elem() | |
setterType = reflect.TypeOf((*Setter)(nil)).Elem() | |
textUnmarshalerType = reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem() | |
binaryUnmarshalerType = reflect.TypeOf((*encoding.BinaryUnmarshaler)(nil)).Elem() | |
) |
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
String[][] peopleToGrades = { | |
{"Tremaine", "A"}, | |
{"Jeremy", "A-"}, | |
{"Yuta", "B"}, | |
{"Steph", "A+"}, | |
{"Klay", "B+"}, | |
{"Damian", "A"}, | |
{"Klay", "A"}, | |
{"Jeremy", "B-"}, | |
}; |
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
String[][] peopleToGrades = { | |
{"Tremaine", "A"}, | |
{"Jeremy", "A-"}, | |
{"Yuta", "B"}, | |
{"Steph", "A+"}, | |
{"Klay", "B+"}, | |
{"Damian", "A"}, | |
{"Klay", "A"}, | |
{"Jeremy", "B-"}, | |
}; |
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
String[][] peopleToGrades = { | |
{"Tremaine", "A"}, | |
{"Jeremy", "A-"}, | |
{"Yuta", "B"}, | |
{"Steph", "A+"}, | |
{"Klay", "B+"}, | |
{"Damian", "A"}, | |
{"Klay", "A"}, | |
{"Jeremy", "B-"}, | |
}; |
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 void keepCountOfCharactersInStringWithGetOrDefault(String str) { | |
HashMap<Character, Integer> map = new HashMap<>(); | |
for (int i = 0; i < str.length(); i++) { | |
map.put(str.charAt(i), map.getOrDefault(str.charAt(i), 0) + 1); | |
} | |
} |
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 void keepCountOfCharactersInString(String str) { | |
HashMap<Character, Integer> map = new HashMap<>(); | |
for (int i = 0; i < str.length(); i++) { | |
if (!map.containsKey(str.charAt(i)) { | |
map.put(str.charAt(i), 1); | |
} else { | |
int currentCount = map.get(str.charAt(i)); |
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
foodList := []string{"pizza", "pasta", "sushi", "pho", "tikka masala"} |
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 main | |
import ( | |
"fmt" | |
"strings" | |
) | |
func main() { | |
foodItems := []string{"pizza", "pasta", "sushi", "pho", "tikka masala"} | |
// space after comma |
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
HashMap<String, Integer> hm = new HashMap<>(); | |
hm.add("a", 1); | |
hm.add("b", 2); | |
hm.add("c", 3); | |
hm.add("d", 4); | |
int b = hm.getOrDefault("b", 99); | |
int e = hm.getOrDefault("e", 99); |
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
HashMap<String, Integer> hm = new HashMap<>(); | |
hm.add("a", 1); | |
hm.add("b", 2); | |
hm.add("c", 3); | |
hm.add("d", 4); | |
int b = hm.getOrDefault("b", 99); |
NewerOlder