JavaTXExamples/src/Main.java

71 lines
2.0 KiB
Java
Raw Permalink Normal View History

import java.util.Vector;
public class Main {
public static void main(String[] args) {
//Id.jav: the identity-function
//applied to an integer
System.out.println(new Id().id(1).toString());
//applied to a string
System.out.println(new Id().id("hallo").toString());
//OL.jav: Overloading
OLMain ol = new OLMain();
//the function main is applied to an integer
System.out.println(ol.main(2));
//the main is applied to a double
System.out.println(ol.main(2.0));
System.out.println(ol.main("Hallo"));
System.out.println(new Fac().getFac(6));
System.out.println(new Faculty().m().apply(6));
//Lambda.jav: An lambda expression applied by the method apply
System.out.println(new Lambda().m().apply(77));
//applyLambda.jav: A defined lambda expression is applied
System.out.println(new applyLambda().m());
Vector<Vector<Integer>> vv = new Vector<Vector<Integer>>();
Vector<Integer> v1 = new Vector<Integer> ();
v1.addElement(2);
v1.addElement(2);
Vector<Integer> v2 = new Vector<Integer> ();
v2.addElement(3);
v2.addElement(3);
Matrix m1 = new Matrix();
m1.addElement(v1);
m1.addElement(v2);
//vv.addElement(v1);
//vv.addElement(v2);
//Matrix m1 = new Matrix(vv);
Vector<Vector<Integer>> vv1 = new Vector<Vector<Integer>>();
Vector<Integer> v3 = new Vector<Integer> ();
v3.addElement(2);
v3.addElement(2);
Vector<Integer> v4 = new Vector<Integer> ();
v4.addElement(3);
v4.addElement(3);
Matrix m2 = new Matrix();
m2.addElement(v3);
m2.addElement(v4);
//vv1.addElement(v3);
//vv1.addElement(v4);
//Matrix m2 = new Matrix(vv1);
//Matrix m3 = m1.mul(vv1);
Matrix m3 = m1.mul(m2);
System.out.println(m1.toString() + " * " + m2.toString() + " = " + m3.toString());
//MatrixOP
MatrixOP mOp1 = new MatrixOP();
mOp1.addElement(v1);
mOp1.addElement(v2);
MatrixOP mOp2 = mOp1.mul.apply(mOp1, mOp1);
System.out.println(m1.toString() + " * " + m2.toString() + " = " + mOp2.toString());
}
}