LLC - Java
h
TheDrone7 (604)

Language learning club - Java

Introduction

Thanks to the repl.it team (especially @amasad and @katyadee), we now have a language learning club about which you can learn more here. We recently had a voice session for GoLang and it was pretty dull and I didn't want that to happen again. So I decided to contribute to the people learning Java myself.

There is going to be a session over voice chat on the repl.it discord server at 06:00 PM CST on Mondays. You can join the discord server by clicking here.


For Beginners

Now that all the info has been shared, here are some resources you can use to get started with Java: -
For book lovers: -

For YouTube video lovers: -


GUI Development with Java

For people who have learned the basics of Java, here are a few YouTube videos that you can watch to learn GUI development with Java.
For people who like to read: -

For people who like videos: -


Android App development

For people who even know about Swing. Java is the most used language for mobile apps development in Android Studio. Click here to learn about Android App development. Here you'll find that there is a new alternative to Java - Kotlin. And it also seems like a sweet choice. You can compare the differences between Java and Kotlin here.


Some code examples

Note: In all the examples the file was named as Main.java which is the default in repl.it. Also, the following examples use the simplest ways possible, these programs could've been made much smaller (except for the first one).

Hello World

/* This program is basically the boilerplate for the language*/
class Main {
  public static void main(String[] args) {
    System.out.println("Hello world!");
  }
}

Hello <name>

// Importing the scanner class for taking input
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    // Declaring the variables
    String name;
    Scanner in = new Scanner(System.in);

    // Getting the name
    System.out.println("What's your name?");
    name = in.nextLine();
      
    // Printing the name
    System.out.println("\nHello, " + name);
  }
}

Factorial

// Importing the Scanner class for taking input
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    // Declaring the variables
    int n, factorial = 1;
    Scanner in = new Scanner(System.in);

    // Getting a number from the user.
    System.out.print("Please enter a number: ");
    n = in.nextInt();
    
    // Calculating the factorial using a simple for loop
    for(int i = 1; i <= n; i++) {
      factorial = factorial * i;
    }

    // Showing the calculated factorial
    System.out.println("\nThe factorial of " + n + " is " + factorial);
  }
}

That's all for now. Visit the above links and learn more for yourself! :P

You are viewing a single comment. View All
katyadee (1151)

Thanks for this! I'll post this in the Discord too :)

TheDrone7 (604)

@katyadee I've already done it twice.