Sign in Join
Wiki copytemporary

Pascal for Java users/de: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-\
21Zurück zu den [[Additional information/de|Zusätzlichen Informationen]].\
3-\
2+
43=Übersetzen von gemeinsamen Programm-Teilen= Die verlinkte englischsprachige Seite zeigt, wie gemeinsame Probleme in verschiedenen Programmiersprachen, einschließlich Java und FreePascal / Object Pascal gelöst werden können.\
54[Rosetta Code](http://rosettacode.org/wiki/Category:Pascal)
65
76# Übersetzen von Java-Operatoren
87
98## Arithmetische Operatoren
109
1110| Java | Pascal | Kommentare |
1211|------|--------|-----------------------------------|
1312|   + |   + |   Addition |
1413|   - |   - |   Subtraktion |
1514|   * |   * |   Multiplikation |
1615|   / |   / |   Gleitkommadivision |
1716|   % |   Mod |   Modulo (Division ohne Rest) |
1817|   ++ |   Inc |   inkrementieren (Hochzählen) |
1918|   -- |   Dec |   dekrementieren (Herunterzählen) |
2019
2120## Relationale Operatoren
2221
2322| Java | Pascal | Kommentare |
2423|-------|--------|------------------|
2524|   == |   = |   gleich |
2625|   != |   \<\> |   ungleich |
2726|   \< |   \< |   kleiner |
2827|   \<= |   \<= |   kleiner gleich |
2928|   \> |   \> |   grösser |
3029|   \>= |   \>= |   grösser gleich |
3130
3231## Logische Operatoren
3332
34-<table>
3533<thead>
36-<tr>
37-<th>Java</th>
38-<th>Pascal</th>
39-<th>Kommentare</th>
40-</tr>
34+
4135</thead>
4236<tbody>
43-<tr>
44-<td>  !</td>
45-<td>  Not</td>
46-<td>  Negation (Den Wahrheitswert in sein Gegenteil ändern)</td>
47-</tr>
48-<tr>
49-<td>  &amp;&amp;</td>
50-<td>  And</td>
51-<td>  logisches UND mit Kurzschlussauswertung<br />
37+
5238  In Free Pascal ist dies die Standard-Compilereinstellung</td>
53-</tr>
54-<tr>
55-<td>  &lt;nowiki&gt;</td>
56-<td></td>
57-<td>  Or</td>
58-</tr>
59-<tr>
60-<td>  &amp;</td>
61-<td>  And</td>
62-<td>  logisches UND mit Komplettauswertung<br />
39+
6340  In Free Pascal ist dies die Compilerdirektive {$B ON}</td>
64-</tr>
65-<tr>
66-<td>  |</td>
67-<td>  Or</td>
68-<td>  logisches ODER mit Komplettauswertung   In Free Pascal ist dies die Compilerdirektive {$B ON}</td>
69-</tr>
70-<tr>
71-<td>  ^</td>
72-<td>  Xor</td>
73-<td>  exclusives ODER</td>
74-</tr>
41+
7542</tbody>
76-</table>
7743
7844## Bit Operatoren
7945
8046| Java | Pascal | Kommentare |
8147|----|----|----|
8248|   ~ |   Not |   Einerkomplement |
8349|   & |   And |   bitweises UND |
8450|   \| |   Or |   bitweises inclusives ODER |
8551|   ^ |   Xor |   bitweises exclusives ODER |
8652|   \>\> |   Shr |   bitweises Rechtsschieben mit Vorzeichen |
8753|   \>\>\> |   ist in Free Pascal nicht vorhanden |   bitweises Rechtsschieben ohne Vorzeichen |
8854|   \<\< |   Shl |   bitweises Linksschieben |
8955
9056## Zuweisungs Operatoren
9157
9258Hinweis: C-artige Operatoren werden in Free Pascal über die Kommandozeilenoption -Sc ermöglicht. C-artige Operatoren werden in Lazarus über die Projekteinstellungen ermöglicht.\
9359{\| class="wikitable" ! Java !! Pascal !! Kommentare \|- \|   = \|   := \|   Einfache Zuweisung \|- \|   += \|   += \|   Additionszuweisung \|- \|   -= \|   -= \|   Subtraktionszuweisung \|- \|   *= \|   *= \|   Multiplikationszuweisung \|- \|   /= \|   /= \|   Divisionszuweisung \|- \|   %= \|   ist in Free Pascal nicht vorhanden \|   Modulo Zuweisung \|- \|   &= \|   ist in Free Pascal nicht vorhanden \|   UND Zuweisung \|- \|   \|= \|   ist in Free Pascal nicht vorhanden \|   ODER Zuweisung \|- \|   ^= \|   ist in Free Pascal nicht vorhanden \|   Exclusive ODER Zuweisung \|- \|   \>\>= \|   ist in Free Pascal nicht vorhanden \|   Rechtsschiebe Zuweisung \|- \|   \>\>\>= \|   ist in Free Pascal nicht vorhanden \|   Rechtsschiebe Zuweisung mit Nullexpansion \|- \|   \<\<= \|   ist in Free Pascal nicht vorhanden \|   Linksschiebe Zuweisung \|}
9460
9561## Sonstige Operatoren
9662
9763| Java | Pascal | |
9864|------|--------|--------------------|
9965|   & |   @ |   Adresse von ... |
10066|   * |   ^ |   Zeiger / Pointer |
10167
10268## Ternärer Operator
10369
104-\
10570{\| class="wikitable" ! Java !! Pascal !! Kommentare \|- \|   ? \|   ist in Free Pascal nicht vorhanden \|   Erlaubt die verkürzte Schreibweise von If-Else Verzweigungen und gibt einen Wert zurück\
10671  Verwendung:\
107-  Ergebnisfeld = Bedingung <b>?</b> Wahrfall : Falschfall\
72+  Ergebnisfeld = Bedingung ? Wahrfall : Falschfall\
10873 \
10974  Beispiel:\
11075  Für ein Maximum in Java:\
11176  max = ( a \> b ) ? a : b;\
11277 \
11378  Dies entspricht in Pascal folgendem if-else-Konstrukt:\
11479  if a \> b Then\
11580      max := a\
11681  else\
11782      max := b;\
11883\|}
11984
12085# Übersetzen von Java Kommentarzeichen
12186
12287| Java | Pascal | Kommentare |
12388|-------|--------|---------------------------|
12489|   /* |   { |   Anfang eines Kommentars |
12590|   /* |   (* |   Anfang eines Kommentars |
12691|   */ |   } |   Ende eines Kommentars |
12792|   */ |   *) |   Ende eines Kommentars |
12893|   // |   // |   Kommentarzeile |
12994
13095# Übersetzen von Java Anweisungsblöcken
13196
13297| Java | Pascal | Kommentare |
13398|------|---------|-------------------------------------------|
13499|   { |   Begin |   Anfang eines Anweisungsblocks |
135100|   } |   End |   Ende / Abschluss eines Anweisungsblocks |
136101
137102# Übersetzen von Java Schleifentypen
138103
139104| Java | Pascal | Kommentare |
140105|----|----|----|
141106|   for( ...; ...; ...++) |   For ... To ... Do |   Kopfgesteuerte Schleife, die hochgezählt wird |
142107|   for(...; ...; ...--) |   For ... Downto ... Do |   Kopfgesteuerte Schleife, die heruntergezählt wird |
143108|   for (Datentyp ...: Array) // For Each Schleife |   For ... in |   Kopfgesteuerte Schleife, für das Durchsuchen von Mengen |
144109|   while (...) |   While ... Do |   Kopfgesteuerte Schleife |
145110|   do ... while(...) |   Repeat ... Until |   Fussgesteuerte Schleife |
146111|   do ... while!(...) |   Repeat ... Until ... Not |   Fussgesteuerte Schleife mit Nichtung des Ergebnisses des Ausdrucks |
147112
148113# Übersetzen von Java Verzweigungen / Bedingungen
149114
150115| Java | Pascal | Kommentare |
151116|----|----|----|
152117|   if(...) |   If ... Then |   If-Bedingung |
153118|   if(...) ... else |   If ... Then ... Else |   If-Bedingung mit Sonstzweig |
154119|   switch(...) case ...: ...break; |   Case ... Of ...: ... End; |   Case-Bedingung |
155120|   switch(...) case ...: ... break; default ...; |   Case ... Of ...: ... Else ... End; |   Case-Bedingung mit Sonst-Zweig |
156121
157122# Übersetzen von Java Verzweigungen- / Schleifenabbrüchen
158123
159124| Java | Pascal | Kommentare |
160125|----|----|----|
161126|   break |   Break |   Die break-Anweisung ermöglicht es, vorzeitig eine Schleife (oder ein switch-case-Konstrukt) zu verlassen |
162127|   continue |   Continue |   Die continue-Anweisung ermöglicht es, den aktuellen Schleifendurchlauf zu beenden |
163128
164129# Übersetzen von Java Prozeduren und Funktionen
165130
166131| Java | Pascal | Kommentare |
167132|----|----|----|
168133|   void Prozedurname(...) |   Procedure Prozedurname(...) |   Unterprogramm (Prozedur) ohne Rückgabewert |
169134|   datentyp Funktionsname(...) |   Function Funktionsname(...): Datentyp |   Unterprogramm (Funktion) mit Rückgabewert |
170135|   return |   FunctionName := ... |   Diese Pascal-Schreibweise ist überholt (deprecated) |
171136|   return |   Result := ... |   Einer Funktion Ihren Rückgabewert zuweisen |
172137
173138# Übersetzen von Java Dateiheadern
174139
175140| Java | Pascal | Kommentare |
176141|----|----|----|
177142|   package ...; |   Unit ...; |   Einbinden der Pascal Unit bzw. des Java Packages |
178143|   import ...; |   Uses ...; |   Bindet Bibliotheken und Klassen ein |
179144|   public static void main(String\[...\] args) {...} |   Program ProgramName; Begin ... End. |   Hauptprogramm |
180145
181146# Übersetzen von Java Datentypen
182147
183148| Java Datentyp | Pascal Datentyp | Speichergrösse in Bits | Range |
184149|----|----|----|----|
185150|   byte |   Shortint |   8-Bit |   -128 .. 127 |
186151|   short |   SmallInt |   16-Bit |   -32768 .. 32767 |
187152|   int |   LongInt |   32-Bit |   -2147483648..2147483647 |
188153|   long |   Int64 |   64-Bit |   -9 223 372 036 854 775 808 .. 9 223 372 036 854 775 807 |
189154|   float |   Single |   32-Bit |   1.5E-45 .. 3.4E+38 |
190155|   double |   Double |   64-Bit |   5.0E-324 .. 1.7E+308 |
191156|   boolean |   Boolean |   8-Bit |   False bzw. True |
192157|   char |   WideChar |   16-Bit |   2 Bytes codieren ein sichtbares Zeichen |
193158|   String |   WideString |   0-Bit bis ∞ |   Zeichenkette |
194159
195160# Übersetzen von Java Aufzählungen (Enumerationen)
196161
197-<table>
198162<thead>
199-<tr>
200-<th>Java</th>
201-<th>Pascal</th>
202-<th>Kommentare</th>
203-</tr>
163+
204164</thead>
205165<tbody>
206-<tr>
207-<td>  enum TheEnum = {MINVALUE, MAXVALUE}</td>
208-<td>  TheEnum = (MINVALUE, MAXVALUE)</td>
209-<td>  Die Konstante MINVALUE enthält den Wert 0<br />
166+
210167  Die Konstante MAXVALUE enthält den Wert 1</td>
211-</tr>
168+
212169</tbody>
213-</table>
214170
215171# Übersetzen von Java Arrays
216172
217173| Java | Pascal | Kommentare |
218174|----|----|----|
219175|   Datentyp\[\] arrayName = new Datentyp\[...\]; |   Datentyp: Array\[...\] Of Datentyp; |   |
220176|   Datentyp arrayVar\[...\] = new Datentyp\[...\]; |   Datentyp: Array\[...\] Of Datentyp; |   |
221177
222178# Übersetzen der Java Objektorientierung
223179
224-<table>
225180<thead>
226-<tr>
227-<th>Java</th>
228-<th>Pascal</th>
229-<th>Kommentare</th>
230-</tr>
181+
231182</thead>
232183<tbody>
233-<tr>
234-<td>  class Klassenname{...}</td>
235-<td>  Klassenname = Class ... End;</td>
236-<td>  Leitet eine Klassendeklaration ein   Schreibweise für Free Pascal und Delphi</td>
237-</tr>
238-<tr>
239-<td>  class Klassenname{...}</td>
240-<td>  Klassenname = Object ... End;</td>
241-<td>  Leitet eine Klassendeklaration ein   Schreibweise für Free Pascal und Turbo Pascal</td>
242-</tr>
243-<tr>
244-<td>  class Klassenname&lt;T&gt; {...}</td>
245-<td>  Generic Klassenname = Class&lt;T&gt; ... End;</td>
246-<td>  Leitet eine Klassendeklaration ein   Generische Klassen werden erst ab Free Pascal 2.2.2 unterstützt</td>
247-</tr>
248-<tr>
249-<td>  Klassenname(...)</td>
250-<td>  Constructor Klassenname.Konstruktorname(...);</td>
251-<td>  In Java ist der Name des Konstructors der Klassenname<br />
184+
252185  In Free Pascal ist der Name des Konstruktors Create</td>
253-</tr>
254-<tr>
255-<td>  abstract</td>
256-<td>  Abstract</td>
257-<td>  Kennzeichnet eine abstrakte Klasse oder eine abstrakte Methode,   d. h. die Klasse oder Methode wird nicht implementiert.</td>
258-</tr>
259-<tr>
260-<td>  implements</td>
261-<td>  SomeClass = Class(SomeInterface)</td>
262-<td>  Implementiert ein Interface</td>
263-</tr>
264-<tr>
265-<td>  extends</td>
266-<td>  SubClass = Class(BaseClass)</td>
267-<td>  Bezeichnet die Klasse von der geerbt wird</td>
268-</tr>
269-<tr>
270-<td>  final</td>
271-<td>  Final</td>
272-<td>  Verhindert das nachträgliche Ändern oder Überschreiben von virtuellen Methoden</td>
273-</tr>
274-<tr>
275-<td>  interface</td>
276-<td>  TheInterface = Interface</td>
277-<td>  Deklariert die Schnittstelle einer Klasse</td>
278-</tr>
279-<tr>
280-<td>  new Class()</td>
281-<td>  InstanzVariable := Klassenname.Create</td>
282-<td>  Initialisierung von Referenz-Datentypen</td>
283-</tr>
284-<tr>
285-<td>  private</td>
286-<td>  Private</td>
287-<td> </td>
288-</tr>
289-<tr>
290-<td>  protected</td>
291-<td>  Protected</td>
292-<td> </td>
293-</tr>
294-<tr>
295-<td>  public</td>
296-<td>  Public</td>
297-<td> </td>
298-</tr>
299-<tr>
300-<td>  static</td>
301-<td>  Static</td>
302-<td> </td>
303-</tr>
304-<tr>
305-<td>  static</td>
306-<td>  Class Function</td>
307-<td> </td>
308-</tr>
309-<tr>
310-<td>  static</td>
311-<td>  Class Procedure</td>
312-<td> </td>
313-</tr>
314-<tr>
315-<td>  super</td>
316-<td>  Inherited</td>
317-<td>  Ruft den Elternkonstruktor auf</td>
318-</tr>
319-<tr>
320-<td>  this</td>
321-<td>  Self</td>
322-<td>  Bezeichnet die Klasse "in der man sich gerade befindet" (Selbstreferenz)</td>
323-</tr>
324-<tr>
325-<td>  transient</td>
326-<td> </td>
327-<td>  Die Variable soll bei der Speicherung von Objekten (Serialisierung) nicht gespeichert werden.</td>
328-</tr>
329-<tr>
330-<td></td>
331-<td></td>
332-<td></td>
333-</tr>
186+
334187</tbody>
335-</table>
336188
337189## Freigabe eines Objektes
338190
339-<table>
340191<thead>
341-<tr>
342-<th>Java</th>
343-<th>Pascal</th>
344-<th>Kommentare</th>
345-</tr>
192+
346193</thead>
347194<tbody>
348-<tr>
349-<td>  null</td>
350-<td>  Nil</td>
351-<td>  Gibt die Referenz auf ein Objekt frei. Mehr ist in Java nicht nötig, den Rest erledigt in Java der Garbage-Collektor.<br />
195+
352196  In Pascal führt der Aufruf FreeAndNil(...) zum selben Ergebnis.</td>
353-</tr>
197+
354198</tbody>
355-</table>
356199
357200## Klassenbestimmung
358201
359202| Java | Pascal | Kommentare |
360203|--------------|--------|----------------------------------------------------|
361204|   instanceof |   Is |   Bestimmt die Klassenzugehörigkeit eines Objektes |
362205
363206## Werfen von Exceptions
364207
365208| Java | Pascal | Kommentare |
366209|----|----|----|
367210|   throw |   Raise |   Wirft eine Exception |
368211|   throws |   ist in Free Pascal nicht vorhanden |   Gibt im Methodenkopf einer Klasse oder Methode an,   welche Ausnahme(n) von der Klasse bzw. Methode ausgelöst werden kann. |
369212
370213## Fangen von Exceptions
371214
372215| Java | Pascal | Kommentare |
373216|----|----|----|
374217|   try { ... } catch { ... } |   Try Begin ... End Except Begin ... End |   Fehlerbehandlung mit einem Try-Block |
375218|   try { ... } catch { ... } finally { ... } |   begin ... try try ... except ... end; finally ... end; ... end; |   Fehlerbehandlung mit einem Block für Abschlussarbeiten |
376219
377220## Threadprogrammierung
378221
379-<table>
380222<thead>
381-<tr>
382-<th>Java</th>
383-<th>Pascal</th>
384-<th>Kommentare</th>
385-</tr>
223+
386224</thead>
387225<tbody>
388-<tr>
389-<td>  synchronized</td>
390-<td>  Synchronize(@...)</td>
391-<td>  Dient der Synchronisation mit dem Hauptthread.</td>
392-</tr>
393-<tr>
394-<td>  volatile</td>
395-<td> </td>
396-<td>  Variablen, die dem Datenaustasch mit anderen Threads dienen, werden in Java mit volatile deklariert.<br />
226+
397227  In Free Pascal sind alle global definierten Variablen volatile.</td>
398-</tr>
228+
399229</tbody>
400-</table>
401230
402231# Aufruf von Fremdfunktionen (z. B. aus Dll's)
403232
404233| Java | Pascal | Kommentare |
405234|----------|-----------|-----------------------------------------|
406235|   native |   StdCall |   Pascal / FPC Standardaufrufkonvention |
407236|   native |   CDecl |   C Standardaufrufkonvention |
408237
409-\
410-\
411238--Olaf 14:28, 24 March 2013 (UTC)
412239
413240---
414241*From the Free Pascal wiki, page "Pascal for Java users/de", as it stood on 2014-01-12 after a change by Olaf, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
415242Category: Code/de
416243Category: Deutsch

Back to history