Last active
October 30, 2016 15:19
-
-
Save peterszatmary/1091362b06ea58017b37964108b96ee8 to your computer and use it in GitHub Desktop.
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 JavaQuestions { | |
public willCompileOrNot() { | |
https://www.github.com/peterszatmary/ | |
System.out.println("will compile or not ?"); | |
} | |
public void question1() { | |
System.out.println(null); | |
} | |
public void question2() { | |
Integer in = null; | |
Integer v = in.valueOf(100); | |
System.out.println("v = " + v); | |
} | |
public void recursiveWalker(File file) { | |
System.out.println(file.getAbsolutePath()); | |
File[] children = file.listFiles(); | |
if (null != children) { | |
for (File child : children) { | |
recursiveWalker(child); | |
} | |
} | |
} | |
public static nonRecursiveWalker(String path, int d) { | |
File root = new File(path); | |
List<File> ex = new LinkedList<>(); | |
ex.add(root); | |
for (int depth = 0; depth < d; depth++) { | |
File[] fs = ex.toArray(new File[ex.size()]); | |
ex.clear(); | |
for (File file: fs) { | |
System.out.println("depth = " + depth + ", file = " + file); | |
if (file.isDirectory()) { | |
ex.addAll(Arrays.asList(file.listFiles())); | |
} | |
} | |
} | |
} | |
public boolean isAcyclic(String s1, String s2) { | |
return (s1 != null && s2 != null) && (s1.length() == s2.length()) && ((s1 + s1).indexOf(s2) != -1); | |
} | |
public void howLong() { | |
long start = System.nanoTime(); | |
// computation | |
long end = System.nanoTime(); | |
System.out.println("time: " + (end - start) + " ns"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment