GNU Compiler for Java: Difference between revisions

Content deleted Content added
Wikipedia:Categories for discussion/Log/2024 October 21#Category:Free compilers and interpreters
 
Line 50:
 
<syntaxhighlight lang="java">
public class IntMyInteger {
public private int i;
{
 
public int i;
public Int(int i) {
this.i = i; }
}
public static Int zero = new Int(0);
 
public int get() {
return i;
}
 
public void set(int j) {
i = j;
}
 
public static final Int zeroZERO = new Int(0);
}
</syntaxhighlight>
Line 62 ⟶ 73:
<syntaxhighlight lang="cpp">
#include <gcj/cni.h>
#include <IntMyInteger>
 
MyInteger* mult(MyInteger& p, int k) {
if (k == 0) {
return IntMyInteger::zeroZERO; // Static member access.
}
 
return new IntMyInteger(p->i.get() * k);
Int *mult(Int *p, int k)
{
if (k == 0)
return Int::zero; // Static member access.
return new Int(p->i * k);
}
</syntaxhighlight>