online compiler java code example

Example 1: online java compiler

Tutorialspoint: https://www.tutorialspoint.com/compile_java_online.php
Jdoodle: https://www.jdoodle.com/online-java-compiler/
Onlinegdb: https://www.onlinegdb.com/online_java_compiler
w3schools: https://www.w3schools.com/java/java_compiler.asp

Example 2: java editor

import java.io.File;
import java.io.IOException;
import java.util.Scanner;
import javax.sound.sampled.*;

public class Main {

	public static void main(String[] args) throws UnsupportedAudioFileException, IOException, LineUnavailableException{
		
		Scanner scanner = new Scanner(System.in);
		
		File file = new File("Level_Up.wav");
		AudioInputStream audioStream = AudioSystem.getAudioInputStream(file);
		Clip clip = AudioSystem.getClip();
		clip.open(audioStream);
		
		String response = "";
			
		while(!response.equals("Q")) {
			System.out.println("P = play, S = Stop, R = Reset, Q = Quit");
			System.out.print("Enter your choice: ");
			
			response = scanner.next();
			response = response.toUpperCase();
			
			switch(response) {
				case ("P"): clip.start();
				break;
				case ("S"): clip.stop();
				break;
				case ("R"): clip.setMicrosecondPosition(0);
				break;
				case ("Q"): clip.close();
				break;
				default: System.out.println("Not a valid response");
			}
		 }
		System.out.println("Byeeee!");	
	}
}

Example 3: online java compiler

SandBox: https://codesandbox.io/

Example 4: compile java online

Compile on w3 schools: ttps://www.w3schools.com/java/java_compiler.asp

Example 5: online java compiler

Repl.it Compiler: click source buttton to go to the website
Pros: You can add files, do javafx and jswing.

Example 6: java online compiler

flag, i
a = [12,22,88,64,9,11]
Repeat till (i<n) {
  if(ith index in a equals 11) {
    flag = "found";
    print(i)
  }
} 
i = i - 1
if(flag not equals "found") {
  print("No such term exists")
}

Tags:

Java Example