CodeGym /Courses /Java Syntax /Loops from Planet Pascal

Loops from Planet Pascal

Java Syntax
Level 4 , Lesson 9
Available

"Hi, buddy. Bilaabo will tell you how this would all look in Pascal."

Pascal
i := 3;
While i >= 0 Do
Begin 
    WriteLn(i);
    i := i - 1;
End;
Java
int i = 3;
while (i >= 0)
{
    System.out.println(i);
    i--;
}
Pascal
i := 0;
While i < 3 Do
Begin 
    WriteLn(i);
    i := i + 1;
End;
Java
int i = 0;
while (i < 3)
{
    System.out.println(i);
    i++;
}
Pascal
isExit := False;
While Not isExit Do
Begin
    ReadLn(s);
    isExit :=  (s = 'exit');
End;
Java
boolean isExit = false;
while (!isExit)
{
    String s = buffer.readLine();
    isExit = s.equals("exit");
}
Pascal
While True Do
    WriteLn('C');
Java
while (true)
    System.out.println('C');
Pascal
While True Do
Begin
    ReadLn(s);
    If  s = 'exit' Then 
        Break;
End;
Java
while (true) 
{
    String s = buffer.readLine();
    if (s.equals("exit")) 
        break;    
}

"This comparison with Pascal might be useful for those who know Pascal."

"You mean you don't? Come on! It's the most popular language on my home planet."

"OK, OK. I believe you that it's cool. And that if I knew it, it would help me."

4
Task
New Java Syntax, level 4, lesson 9
Locked
How do hard drives work?
Can you believe that modern hard drives hold 300,000,000 times more information than IBM’s first device from 1957? Nowadays they can easily hold more information than any library, and their capacity is still increasing. But how do they store such huge amounts of data? In this TED-Ed video, Kanawat Senanan explains how these powerful tools were created.
Comments (29)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
Usman Level 8, Glasgow, United Kingdom
28 June 2021
Java > Pascal
Sinisa Level 11, Banja Luka, Bosnia and Herzegovina
17 February 2021
No curly braces in Python but indentation, no variable declaration (big thing!), is less verbose, coding goes more quickly, code is more readable, faster to execute (Java is faster once it compiles though). Java is more complicated and since there is Kotlin which is since late 2019. Android-preferred development language, Java will probably slowly decline. However the very concepts we learn in Java are applicable in other languages easily.
Joe M Level 47, Owings Mills, United States
29 September 2020
helpful
Laura Level 7, Lübeck, Deutschland
29 August 2020
I like to see the comparison to other programming languages
Ibrahim Level 9, Minneapolis, United States
20 August 2020
Although I wished to see a comparison to Python or a more moderate language, it won't hurt to glance over to Pascal and see how similar/ different it is from Java because one may appreciate knowing that by learning java, he/she is also learning common programming concepts and more or less syntax of other programming languages.
Chase Level 17
18 August 2020
Java is my first language, I dont really think having this information is useful to most of us. We are trying to learn java right?
Andrei Level 41
23 September 2020
I believe it's an interesting parallel to see how other programming languages look like.
Agent Smith Level 38
8 August 2020
Hmmm, not sure if comparisons with Pascal are all that helpful. Maybe comparisons with C/C++, Python or JavaScript would be more practical for newbies?
Dinesh Level 7, Delhi, India
29 October 2020
Yes, I Agree
Attila Level 7, Hainault, United Kingdom
3 July 2020
Joci , is anyone working already as a programmer ?
Enoma Uwaifo Level 1, Nigeria, Nigeria
12 March 2020
Good exercises so far.
Johannes Level 27, Centurion, Pretoria, South-Africa
2 March 2020
Course is wonderful so far, no complaints, just want to mention that I am trying to learn Java, and keeping up is hard enough, so I don't see the reason we're being shown Pascal at all ? have a nice day.
Erik Kristofer Anderson Level 15, Chicago, United States
14 April 2020
I find it helpful to see English equivalents of Java Symbols. But if it's not helping you, you can probably just ignore the Pascal.