Kotlinlearncs.online LogoJava

    ← Prev

    Index

    Next →

    Kotlin
    Java
    • Variables and Types : 1

    • Hello, world! : 0

    Hello, world!

    System.out.println("Welcome to learncs.online!");

    Welcome to learncs.online! Your journey in computer science and programming starts now. We’re so excited that you are here.

    You Are Not Alone
    You Are Not Alone

    Learning computer science and programming is not always easy. You will get frustrated along the way. But you won’t need to struggle alone. This course was created by a supportive community of teachers and learners at the University of Illinois. And you can find more help and connect with other students on our course forum: https://forum.learncs.online. Please take a minute to log in and create an account as you get started!

    Why This Course?
    Why This Course?

    Before we talk about how this course works, let’s address why: Why take this course, and why learn to program at all? (Feel free to skip ahead if you’re already convinced and want to get started…)

    Why Learn to Program?
    Why Learn to Program?

    If you’re here, you may already have reasons that you want to learn how to program and the basics of computer science. You might think that knowing these things will help you get a job—and that might be true! You might have real-world problems that you want to solve, and think that learning to create computer programs can help—and it might! Or you might have noticed that your life is increasingly lived with and around computers, and want to know a bit more about how they work.

    These are all great and valid reasons to want to programming and computer science. But if you asked us to just pick a few, here are the ones that we think are the most compelling, just in case you’re still not quite convinced:

    As Fred Brooks put it:

    “The programmer, like the poet, works only slightly removed from pure thought-stuff. They build their castles in the air, from air, creating by exertion of the imagination. Few media of creation are so flexible, so easy to polish and rework, so readily capable of realizing grand conceptual structures.”

    Why learncs.online?
    Why learncs.online?

    So you want to learn to program and a bit about computer science. Great! But why use this site? After all, there are tons of great ways to learn to program online, many of them—like this site—completely free.

    First and foremost, you should use whatever learning resources work best for you. If you’re struggling to make progress here, try something else! The great thing about the diversity of online learning resources for learning to program is that there is almost certainly something out there that works for you.

    That said, and without taking anything away from all of the other great online learning resources for beginning programmers, there are a few things about this site that distinguish it from the many other options:

    1. Interactive live-coding walkthroughs. You don’t learn anything by watching. You learn by doing. That’s why we’ve created a new interactive walkthrough component that we use for all of our live coding demonstrations. At any point during the demo, you can pause and interact with the code yourself—run the program, change things, and generally experiment freely. No other site that we know of offers this feature.

    2. A community of instructors. Sometimes an explanation for a few idea might not click with you right away. When that happens, it can be helpful to hear the concept explained differently. That’s why our materials include contributions from not one, not two, but literally hundreds of different instructors—including both faculty and students. For most concepts, we provide at least two alternative explanations, and for some many more. No other site that we know of provides access to such a large community of instructors.

    3. Tons of programming exercises with code quality feedback. Practice makes perfect, particularly when learning to program. That’s why each of our lessons includes multiple programming exercises, which you can complete right in your browser. And we don’t just provide feedback on whether your code is correct, but also on whether it is good—properly formatted, well-constructed, and reasonably efficient. No other site that we know of provides this kind of code quality analysis.

    4. Debugging exercises. Learning to spot small mistakes is a critical part of learning to program. That’s why we’ve created tons of debugging exercises to help you practice this essential skill. You’ll find them located throughout many of our lessons. No other site that we know of provides as much practice with this core programming ability.

    5. Completely browser based. Unlike some other courses that teach Java or Kotlin, you can learn everything on this site with just your web browser. There’s no extra software to install. We’ve put a lot of effort into building high-performance systems for allowing you to interact with Java and Kotlin code. We hope you enjoy them!

    Check out our innovations page for a longer description of the innovative technologies that power this site.

    Our Approach to Java
    Our Approach to Java

    You may skip this section if you’re ready to get started!

    Our approach to teaching Java is a bit different than some other courses. Frequently they start with this example:

    public class Example {
    public static void main(String[] unused) {
    System.out.println("Hello, world!");
    }
    }

    But there is so much to understand here already! What is a class? What is public? What is static? And void? And main? It’s easy to forget what it’s like to be learning to program for the first time, and the importance of taking things one small step at a time.

    We start like this:

    System.out.println("Hello, world!");

    You will understand that entire example above by the time you are done, and by the middle of the course you’ll be writing syntactically-valid Java code that you could run anywhere. But we work from the inside out—methods when you’re ready for methods, and objects and classes when you’re ready for objects.

    Our approach is different. Does it work? Yes! It does. Thousands of students at the University of Illinois have successfully completed our introductory programming course using this approach. Our course includes Android programming during the second half, and so we know our students are perfectly capable of writing and working with full-strength Java, even if we provide them with a gentler introduction at the beginning.(1)

    How This Course Works
    How This Course Works

    learncs.online comprises a series of lessons—just like this one. Lessons combine text, videos, code examples, and interactive walkthroughs, combined to teach a single concept or new idea. Each concludes with one or more small programming exercises for you to complete, to determine whether you’ve grasped the new lesson concepts.

    We suggest that you complete each lesson before moving on to the next. We also suggest that you complete at most one or two lessons per day, and then pause before continuing. Programming is a skill, best learned bit by bit, one day at a time, and through so-called spaced repetition.

    Your brain will get tired when you are getting started! In many ways, your brain is like a muscle. When you begin exercising it through programming, it tires easily, and you’ll need to leave time for it to recover and get stronger. Over time, as you internalize the core ideas, you’ll find things come easier and easier, and you can move a bit faster. But don’t expect to be able to rush through all of this content all at once. Like anything worth learning, learning to program takes time. But if you apply yourself, you will succeed.

    Getting Help
    Getting Help

    The best way to get help with the learncs.online materials is through our course forum. There you’ll find students and instructors available to answer questions, commiserate, offer support, and engage in meme appreciation. When you have a question, ask it on the forum.

    However! Please do not post attempted solution code on the forum. You may post output from your submissions, and other information about what you are trying and what is going wrong. But posting solutions ruins the experience for other learners.

    Lesson Components
    Lesson Components

    Our lessons contain a mixture of different types of content. Some of each lesson will be text, like what you’re reading.

    Playgrounds
    Playgrounds

    We also use a lot of interactive examples, like this one:

    System.out.println("Play with me!");

    These playgrounds are editable and runnable. They are here for you to play with. Run them, modify the code, run them again. You’ll learn to program must faster if you allow yourself to experiment.

    When working on larger examples your changes will automatically be saved, but you can always return to the original contents. You’ll know that an editor is saving your work when you see the green check mark in the upper right-hand corner, like this:

    System.out.println("Play with me!");

    Interactive Walkthroughs
    Interactive Walkthroughs

    Sometimes we want to show you how to do something using code. In that case, we’ll provide an interactive walkthrough, which combines audio with an animated editor. Here’s an example.

    System.out.println("Hello, world");

    Many of our walkthroughs include contributions from multiple course staff members. Confused? Try another explanation! Still confused? Ask on the forum.

    Video Content
    Video Content

    Finally, we’ll also sometimes use video to explain a concept or make a particular point. Or, for us to introduce some of our pets!

    Practice Problems
    Practice Problems

    Mixed in to each lesson you’ll find practice problems, like the one below. Solutions to the practice problem will be available once you’ve attempted it a few times. These problems will help test your understanding as you go along, and prepare you for that lesson’s homework problem.

    Created By: Geoffrey Challen
    / Version: 2020.6.0

    As we learn to communicate with these incredibly powerful machines, we frequently need them to tell us something about what they are doing as they run our program. We do this by using so-called print statements.

    In Java, the programming language we'll be learning together, we use the function System.out.println to print a message to the console. The code below is already displaying a message. But to complete this problem you need to modify the code so that it prints "Hello, world!" (Note that you don't need to print the quotation marks, just what's between them.)

    Debugging Challenges
    Debugging Challenges

    As you learn to write computer code, you’ll need to be able to identify and fix small mistakes with your programs. To give you more practice with this, lessons also include debugging challenges, like the one below. These give you practice at finding and identifying small mistakes in computer programs.


    What is CS 124 or CS 125?
    What is CS 124 or CS 125?

    Throughout the lesson videos and walkthroughs, you may hear references to CS 124, CS 125, or the University of Illinois. The learncs.online materials were created to support an introductory computer science course at the University of Illinois, originally numbered CS 125 and then recently renumbered to CS 124. We think that CS 124 is the best introductory computer science course on the planet! Hopefully, by the time you’re done learning using our materials, you’ll agree. Click here to find out more about learncs.online.

    Who are your instructors?
    Who are your instructors?

    One unique feature of learncs.online is that we incorporate contributions from many different instructors. Over 200 instructors and students have contributed to our online materials. Notable contributors include:

    What is Code?
    What is Code?

    We’ll be reading and writing a lot of Java computer code together. But what is code?

    Computers are incredibly powerful and versatile machines. If you can get them to do what you want, you can solve any problem and change the world. But how do we tell them what to do?

    Here’s one of the simplest examples of a computer program—one so special that it has its own name: “Hello, world!“.

    System.out.println("Hello, world");

    Run the code above and see what happens. Now, play with the code. Experiment and see what happens. Maybe try and see if you can get the code to print something other than “Hello, world!“. See if you can break the code, and find out what happens when the code doesn’t run. Nothing bad will happen! But see if you can figure out what is wrong with the code based on the output produced by the computer.

    Your First Homework Problem
    Your First Homework Problem

    Each lesson concludes with a homework problem to complete. Solutions to the homework problem will be available once you complete it!

    Created By: Geoffrey Challen
    / Version: 2022.6.0

    As we learn to communicate with these incredibly powerful machines, we frequently need them to tell us something about what they are doing as they run our program. We do this by using so-called print statements.

    In Java we use the function System.out.println to print a message to the console. The code below is already displaying a message. But to complete this problem you need to modify the code so that it prints "Hello, learncs.online!" (Note that you don't need to print the quotation marks, just what's between them.)

    More Practice

    Need more practice? Head over to the practice page.