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
@Scope(ScopeType.STATELESS) | |
@BypassInterceptors | |
@Install(precedence = Install.APPLICATION, dependencies = "org.jboss.seam.security.identity") | |
@Name("org.jboss.seam.core.resourceLoader") | |
public class DatabaseResourceLoader extends ResourceLoader { | |
@Override | |
public ResourceBundle loadBundle(String bundleName) { | |
return new ResourceBundle() { | |
public Enumeration<String> getKeys() { | |
//Locale locale = org.jboss.seam.core.Locale.instance(); |
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 MissingNumbers { | |
public static void main(String[] args) { | |
//In the below code: Array Size = 8 and n = 10. | |
//So 2 missing numbers! | |
int n = 10; | |
int[] intArr = new int[] {3,1,2,5,4,7,10,8}; | |
MissingNumbers missingNums = new MissingNumbers(); | |
int[] missingNums = missingNums.findMissingNumber(intArr, 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
public class MissingNumber { | |
public static void main(String[] args) { | |
MissingNumber missingNum = new MissingNumber(); | |
System.out.println("Missing Number : " + missingNum.findMissingNum(new int[] {3,1,2,5,4,7,9,8}, 9)); | |
} | |
private int findMissingNum(int[] intArray, int n) { | |
int res = 0; | |
int sum = 0; |
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
<pluginrepositories> | |
<pluginrepository> | |
<name>oss.sonatype.org</name> | |
<id>oss.sonatype.org</id> | |
<url>http://oss.sonatype.org/content/groups/public</url> | |
</pluginRepository> | |
</pluginRepositories> |
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
<build> | |
<plugins> | |
<plugin> | |
<groupid>net.alchim31.maven</groupId> | |
<artifactid>yuicompressor-maven-plugin</artifactId> | |
<executions> | |
<execution> | |
<goals> | |
<goal>compress</goal> | |
</goals> |
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
<build> | |
<plugins> | |
<plugin> | |
<groupid>org.apache.maven.plugins</groupId> | |
<artifactid>maven-shade-plugin</artifactId> | |
<version>1.4</version> | |
<executions> | |
<execution> | |
<phase>package</phase> | |
<goals> |
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.math.BigInteger; | |
public class BigIntTest { | |
public static void main(String[] args) { | |
BigInteger bigInt1 = new BigInteger("1000000000000000"); | |
BigInteger bigInt2 = new BigInteger("1000000000000500"); | |
//Loop from bigInt1 to bigInt2 | |
for(BigInteger bigInt = bigInt1; bigInt.compareTo(bigInt2) < 0; bigInt = bigInt.add(BigInteger.ONE)) { | |
System.out.println("I'm so big now : " + bigInt); |
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.io.File; | |
import java.io.FilenameFilter; | |
import java.io.IOException; | |
import java.nio.charset.Charset; | |
import java.util.Arrays; | |
import java.util.Locale; | |
import javax.tools.Diagnostic; | |
import javax.tools.DiagnosticCollector; | |
import javax.tools.JavaCompiler; | |
import javax.tools.JavaFileObject; |
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 Googol { | |
public static void main(String[] args) { | |
long googol1 = (long) Math.pow(10,100); | |
System.out.println("Googol1 : " + googol1); | |
System.out.println("Max Value of Long : " + Long.MAX_VALUE); | |
BigDecimal googol2 = new BigDecimal(Math.pow(10,100) + ""); | |
System.out.println("Googol2 : " + googol2); | |
BigDecimal bigDecimal = googol2.multiply(new BigDecimal(Math.PI + "")); |
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 ReverseWords { | |
public String reverseWords(String phrase) { | |
List<string> wordList = Arrays.asList(phrase.split("[ ]")); | |
Collections.reverse(wordList); | |
StringBuilder sbReverseString = new StringBuilder(); | |
for(String word: wordList) { |