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 StudentScore { | |
public String id; | |
public int score; | |
/* | |
// Constructor | |
0) The name of the method has to be the same as the class name | |
1) Has no return type | |
2) Automatically called whenever you "new" a class | |
3) You can have multiple constructors as long as "signature" different |
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
class Untitled { | |
static class Obj { | |
protected int x = 3; | |
protected int getX() { | |
return x; | |
} | |
} | |
static class Shape extends Obj { | |
private int x = 4; |
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
class Untitled { | |
// | |
// Polymorphism | |
// | |
static class Object { | |
protected int x = 8; | |
} | |
static class Animal extends Object { | |
private int x = 3; |
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.*; | |
class Untitled { | |
private int[] memo = new int[1000]; | |
Untitled() { | |
for(int idx = 0; idx < memo.length; idx++) { | |
memo[idx] = -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
language: objective-c | |
xcode_workspace: pop.xcworkspace | |
xcode_scheme: pop | |
xcode_sdk: iphonesimulator7.0 | |
before_script: | |
- brew update | |
- brew upgrade xctool | |
before_install: | |
- export LANG=en_US.UTF-8 | |
- gem install cocoapods -v '0.32.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 class Untitled { | |
public static void main (String[]args){ | |
int []y={5,31,2,-1,1,0,6,7,8}; | |
sort13(y); | |
print(y); | |
} | |
public static void sort13(int [] a){ | |
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
class Untitled { | |
public static void main(String[] args) { | |
String test = "love"; | |
String[] newt = test.split(""); // this line basically splits "love" into ["l", "o", "v", "e"] | |
for(String c : newt) // this is Java syntax to loop over each array element | |
System.out.print(c+" "); | |
} | |
} |
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 TestNumOfChar { | |
private static int NumOfChar(String s, String x) { | |
if(s.length() == 0) | |
return 0; | |
if(s.charAt(0) == x.charAt(0)) | |
return 1 + NumOfChar(s.substring(1), x); | |
else | |
return NumOfChar(s.substring(1), x); | |
} |
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
printfn "We are going to calculate sum of squares upto 5!" | |
let square x = | |
x * x | |
let sumOfSquares n = | |
[1..n] |> List.map square |> List.sum | |
printfn "Answer: %d" (sumOfSquares 5) |
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 <Foundation/Foundation.h> | |
int main(int argc, char *argv[]) { | |
@autoreleasepool { | |
for(int i = 0; i < 500; i++) { | |
int j; | |
for (j = 2 ; j <= i - 1 ; j++ ) { | |
if (i%j == 0) | |
break; |