Created
January 2, 2016 14:23
-
-
Save abd3lraouf/efa13e4349635a7cfe79 to your computer and use it in GitHub Desktop.
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
[package]>java.util.* | |
Random | |
>Methods: | |
nextInt(); | |
nextFloat(); // etc ... | |
GregorianCalendar | |
>Methods: | |
calendar.get(constant); | |
calendar.setTimeInMillis(long); | |
calendar.setTime(Date); | |
>Constants: | |
GregorianCalendar.DAY_OF_MONTH | |
GregorianCalendar.YEAR | |
GregorianCalendar.MONTH(0-->11) | |
Date | |
>Methods: | |
setTime(long); | |
getTime():long | |
[package]>java.math.* | |
BigInteger | |
BigDecimal | |
UNCLASSIFIED | |
>Instructions: | |
// copy arrays | |
System.arraycopy(src,srcStartIndex,dst,dstStartIndex,length); | |
// character and char | |
Character.isUpperCase(char); | |
char c=Character.toLowerCase(char); | |
// convert array to string (can be used inside toString() ) | |
Arrays.toString(array); // like this [a, b, d, o] | |
>Methods: | |
// parseInt | |
public static int parseInt(char[]charArray){ | |
int sum=0; | |
for(char c:charArray){ | |
sum=(sum*10)+(c-'0'); | |
} | |
return sum; | |
} | |
// is Prime | |
public static boolean isPrime(int number){ | |
for(int divisor=2;divisor<=number/2;divisor++){ | |
if(number%divisor==0){ | |
return false; | |
} | |
} | |
return true; | |
} | |
// prime Factors | |
public static StackOfIntegers primeFactors(long number){ | |
StackOfIntegers stack=new StackOfIntegers(5); | |
long temp=number; | |
for(int i=2;i<=temp;i++){ | |
if(temp%i==0){ | |
stack.push(i); // prime factor | |
temp/=i; | |
i--; | |
} | |
} | |
return stack; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment