summaryrefslogtreecommitdiff
path: root/java/java.tex
blob: e8e132ca5ea79704932ea61bb01973de5261317b (plain)
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
\section{Java}
\lstset{language=Java}

\subsection{Introduction}

\begin{itemize}
\item Compilen: \lstinline{javac main.java}
\item Ausführen: \lstinline{java main < sample.in}
\item Eingabe:
\begin{lstlisting}
Scanner in = new Scanner(System.in); //java.util.Scanner
String line = in.nextLine(); //reads the next line of the input
int num = in.nextInt(); //reads the next token of the input as an int
double num2 = in.nextDouble(); //reads the next token of the input as a double
\end{lstlisting}
\item Ausgabe:
\begin{lstlisting}
//Ausgabe in StringBuilder schreiben und am Ende alles auf einmal ausgeben -> viel schneller
StringBuilder sb = new StringBuilder(); //java.lang.StringBuilder
sb.append("Hallo Welt");
System.out.print(sb.toString());
\end{lstlisting}
\end{itemize}

\subsection{BigInteger}
Hier ein kleiner überblick über die Methoden der Klasse BigInteger:
\begin{lstlisting}
//Returns this +,*,/,- val
BigInteger add(BigInteger val), multiply(BigInteger val), divide(BigInteger val), substract(BigInteger val)

//Returns this\(^e\)
BigInteger pow(BigInteger e)

//Bit-Operations
BigInteger and(BigInteger val), or(BigInteger val), xor(BigInteger val), not(), shiftLeft(int n), shiftRight(int n)

//Returns the greatest common divisor of abs(this) and abs(val)
BigInteger gcd(BigInteger val)

//Returns this mod m, this\(^{-1}\) mod m, this\(^e\) mod m
BigInteger mod(BigInteger m), modInverse(BigInteger m), modPow(BigInteger e, BigInteger m)

//Returns the next number that is greater than this and that is probably a prime.
BigInteger  nextProbablePrime()

//Converting BigInteger. Attention: If the BigInteger is to big the lowest bits were choosen which fits into the converted data-type.
int intValue(), long longValue(), float floatValue(), double doubleValue() 
\end{lstlisting}
\lstset{language=C++}