Skip to content

Commit

Permalink
Formatting examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ronyhe committed Jul 31, 2018
1 parent 173ec33 commit 81717ca
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Let's create the file Main.java.
We expect this class to store the int value 10 in the static variable `someInt`.
```java

public class Main {
public static int someInt = 5;

Expand Down Expand Up @@ -82,35 +81,35 @@ Near the end, you can see this line:
PutStatic(class_name='Main', field_name='someInt', value=JvmValue(<Integer>, 10))
```
So, our expectations were met.
When using pyjvm this class indeed stores the int value 10 in the static variable `someInt`.
When using pyjvm, this class indeed stores the int value 10 in the static variable `someInt`.


### Something a bit more complex
Let's change Main.java and recompile:
```java
public class Main {
public static int someInt;
public static int someInt;

public static void main(String[] args) {
Main instance = new Main(5);
instance.add(3);
instance.add(2);
someInt = instance.getNum();
}
public static void main(String[] args) {
Main instance = new Main(5);
instance.add(3);
instance.add(2);
someInt = instance.getNum();
}

private int num;

public Main(int num) {
this.num = num;
}

public void add(int a) {
num += a;
}
public void add(int a) {
num += a;
}

public int getNum() {
return num;
}
public int getNum() {
return num;
}
}
```
We still expect it to store 10 in `someInt`, but there's more going on here:
Expand Down

0 comments on commit 81717ca

Please sign in to comment.