-
Notifications
You must be signed in to change notification settings - Fork 0
/
java.html
150 lines (146 loc) · 4.78 KB
/
java.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Java</title>
<style>body{font-size: 12px}code,pre{margin:0;padding:0;}
body>pre{white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space: -o-pre-wrap;word-wrap:break-word;}
</style>
</head>
<body>
<h1>Java, JavaLink, Symbolic Java</h1>
<p><a href="https://stackoverflow.com/questions/4732544/why-are-only-final-variables-accessible-in-anonymous-class">Only Final variables accessible</a>
<br>Conversion of Types between Java and the Wolfram Language. <a href="http://mathematica.stackexchange.com/questions/89179/how-to-discover-a-java-class-path-used-by-loadjavaclass">Discover Java Class</a> <a href="http://mathematica.stackexchange.com/questions/18349/override-to-mock-java-classes">Mock Java Classes </a><a href="http://mathematica.stackexchange.com/questions/30604/paste-data-into-mathematica-with-formatting">Paste Text With Formatting</a> <a href="http://mathematica.stackexchange.com/questions/138102/define-alternative-symbol-for-java-classes">Define alternative symbol for Java classes </a>.
My biggest frustration with sub classing Java is the different types not to mention the classes. JS is prototype based which is easier to deal with IMO. <a href="http://limeblack.github.io/JavaInsideMathematica.nb">JaveInsideMathematica</a>. .NET has the same gripes and therefore isn't really any easier <a href="http://limeblack.github.io/CsharpExport.nb">CsharExport</a>.
<br>
Array[] \[Colon]<br>
JavaMethodCalls\[Dot]<br>
int x = 2; \[CircleDot]</p>
<table style="width:100%" border="1"><tbody>
<tr>
<td width="25%"><pre>Java
javac Hello.java
java Hello.java</pre></td>
<td width="25%">Symbolic Java</td>
<td width="25%">Expanded Symbolic Java</td>
<td width="25%">Symbolic JavaLink<br>
JavaLink[] </td>
</tr>
<tr>
<td>MyClass o = new MyClass(args);<br>int[][] ia = new int[10][20];<br>String[] sa = new String[10];</td>
<td>o= new["MyClass",args]<br>
(* Simplified *)<br>
o= new MyClass[args]<br>
int[][] ia = new int[10][20];<br>
int : _: _ \[CircleDot] ia = new int : 10 : 20;<br>
String[] sa = new String[10];</td>
<td>o = Times[new,MyClass]<br>
Times[int[][] ia] = Times[new int[10][20]];<br>
int[][] ia</td>
<td width="25%">o = LoadJavaClass["MyClass",args];<br>
</td>
</tr>
<tr>
<td>o.Method(args);</td>
<td>o\[Dot]Method[args];</td>
<td></td>
<td width="25%">o@Method[args];</td>
</tr>
<tr>
<td>
<div>
<pre>//Inner Class
Box.Filler f = new Box.Filler(args);</pre>
</div>
</td>
<td>
<pre id="i_15_out_text">Box$Filler@f = new["java.swing.Box$Filler", args]</pre>
</td>
<td></td>
<td width="25%">
<pre id="i_15_out_text">f = JavaNew["java.swing.Box$Filler", args]</pre>
</td>
</tr>
<tr>
<td><pre>o.prop = 1; val = obj.prop;</pre></td>
<td>o\[Dot]prop = 1;
val = obj\[Dot]prop;</td>
<td></td>
<td width="25%"><pre>o@prop = 1;val = o@prop;</pre></td>
</tr>
<tr>
<td>
<pre></pre>
</td>
<td></td>
<td></td>
<td width="25%">MyClass`StaticMethod[args];</td>
</tr>
<tr>
<td>MyClass.StaticPropertyOrField = 1;<br>
value = MyClass.StaticPropertyOrField;</td>
<td></td>
<td></td>
<td width="25%">MyClass`StaticPropertyOrField = 1;<br>
value = MyClass`StaticPropertyOrField;</td>
</tr>
<tr>
<td><pre>int i = 1;
double d = 2;
int[] anArray;
anArray = new int[10][20];</pre>
</td>
<td>
<pre>int \[CircleDot] i = 23;
double \[CircleDot] d = double \[CircleDot] 2;
anArray = int \[Colon] 10;</pre>
</td>
<td></td>
<td width="25%">i = 23;</td>
</tr>
<tr>
<td>
<pre>public class MyClass {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
public void Method(){<br>
System.out.println("Method")}
public static void staticMethod(){
System.out.println("Static method");
}
public MyClass(){<br>System.out.println("Test");}
}</pre>
</td>
<td>
<pre>public@class@MyClass[
public@static@void@main[String@args[]][
System@out@println["Hello, World");
],
public@MyClass[][
System@out@println[""];
]
]
public class MyClass[
public static void main[String args[]][
System:out:println["Hello, World");
],
public@MyClass[][
System@out@println[""];
]
]
</pre>
</td>
<td></td>
<td width="25%"><pre></pre></td>
</tr>
<tr>
<td></td>
<td>For, If, Else, </td>
<td></td>
<td width="25%"></td>
</tr>
</tbody>
</table>
</body>
</html>