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 Goto { | |
public static void main(String[] args) { | |
int count = 0; | |
Goto: | |
for(int i = 0; i < 10; i +=1) { | |
for(int j = 0; j < 10; j += 1) { | |
System.out.println("hello" + count++); | |
break Goto; | |
} |
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 static double entropy(List<? extends Comparable> values) { | |
final Map<Comparable, Long> valueOccurances = new HashMap<Comparable, Long>(); | |
for (Comparable value : values) { | |
Long valueOccurance = valueOccurances.get(value); | |
valueOccurances.put(value, valueOccurance == null ? 1L : ++valueOccurance); | |
} | |
double combinedEntropy = 0.0d; |
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
vioplot2 <- function (x, ..., range = 1.5, h = NULL, ylim = NULL, names = NULL, | |
horizontal = FALSE, col = "magenta", border = "black", lty = 1, | |
lwd = 1, rectCol = "black", colMed = "white", pchMed = 19, | |
at, add = FALSE, wex = 1, drawRect = TRUE, side="both") | |
{ | |
datas <- list(x, ...) | |
n <- length(datas) | |
if (missing(at)) | |
at <- 1:n | |
upper <- vector(mode = "numeric", length = n) |
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 self.vpalepu.stackoverflow; | |
import java.io.File; | |
import java.io.FileInputStream; | |
import java.io.IOException; | |
import org.objectweb.asm.ClassReader; | |
import org.objectweb.asm.ClassVisitor; | |
import org.objectweb.asm.ClassWriter; | |
import org.objectweb.asm.MethodVisitor; |
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
Using Underscore Characters in Numeric Literals | |
In Java SE 7 and later, any number of underscore characters (_) can appear anywhere between digits in a numerical literal. This feature enables you, for example. to separate groups of digits in numeric literals, which can improve the readability of your code. | |
For instance, if your code contains numbers with many digits, you can use an underscore character to separate digits in groups of three, similar to how you would use a punctuation mark like a comma, or a space, as a separator. | |
The following example shows other ways you can use the underscore in numeric literals: | |
long creditCardNumber = 1234_5678_9012_3456L; | |
long socialSecurityNumber = 999_99_9999L; |
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
# This is a comment | |
=begin | |
This is a multiline comment | |
No-one uses them | |
You shouldn't either | |
=end | |
# First and foremost: Everything is an object. |
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.*; | |
import java.io.*; | |
public class FootTrafficAnalysis { | |
HashMap<Integer, HashMap<Integer, ArrayList<Integer>>> dataStore = | |
new HashMap<Integer, HashMap<Integer, ArrayList<Integer>>>(); | |
public static void main(String[] args) { | |
new FootTrafficAnalysis().channelLogFile(new File("simple.in")); |
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 static char[] parseMethodArguments(String desc) { | |
String[] splitDesc = splitMethodDesc(desc); | |
char[] returnChars = new char[splitDesc.length]; | |
int count = 0; | |
for(String type : splitDesc) { | |
if(type.startsWith("L") || type.startsWith("[")) { | |
returnChars[count] = 'L'; | |
} | |
else { | |
if(type.length() > 1) { throw new RuntimeException(); } |
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.*; | |
public class CommonMapSetValues { | |
public static void main(String[] args) { | |
CommonMapSetValues obj = new CommonMapSetValues(); | |
obj.addKeyValue("abc", new String[] {"ax1","au2","au3"}); | |
obj.addKeyValue("def", new String[] {"ax1","au6"}); | |
obj.addKeyValue("ijk", new String[] {"ax1","au2"}); | |
System.out.println(obj.toString()); |
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 CloneTest implements Cloneable { | |
public static void main(String[] args) { | |
CloneTest original = new CloneTest("dummyname", new StringBuffer("Molly"), 1); | |
CloneTest clone = (CloneTest)original.clone(); | |
System.out.println("orignal.name2:" + original.name2.toString()); | |
System.out.println("clone.name2:" + clone.name2.toString()); | |
clone.setName2("Dolly"); | |
System.out.println("orignal.name2 (after clone update):" + original.name2.toString()); | |
System.out.println("clone.name2: (after clone update):" + clone.name2.toString()); | |
} |
NewerOlder