1interface Foo141
2{
3 int k = 0; /* Line 3 */
4}
5public class Test141 implements Foo141
6{
7 public static void main(String args[])
8 {
9 int i;
10 Test141 test141 = new Test141();
11 i = test141.k; /* Line 11 */
12 i = Test141.k;
13 i = Foo141.k;
14 }
15}
1Repl.it Compiler: click source buttton to go to the website
2Pros: You can add files, do javafx and jswing.
1import java.io.File;
2import java.io.IOException;
3import java.util.Scanner;
4import javax.sound.sampled.*;
5
6public class Main {
7
8 public static void main(String[] args) throws UnsupportedAudioFileException, IOException, LineUnavailableException{
9
10 Scanner scanner = new Scanner(System.in);
11
12 File file = new File("Level_Up.wav");
13 AudioInputStream audioStream = AudioSystem.getAudioInputStream(file);
14 Clip clip = AudioSystem.getClip();
15 clip.open(audioStream);
16
17 String response = "";
18
19 while(!response.equals("Q")) {
20 System.out.println("P = play, S = Stop, R = Reset, Q = Quit");
21 System.out.print("Enter your choice: ");
22
23 response = scanner.next();
24 response = response.toUpperCase();
25
26 switch(response) {
27 case ("P"): clip.start();
28 break;
29 case ("S"): clip.stop();
30 break;
31 case ("R"): clip.setMicrosecondPosition(0);
32 break;
33 case ("Q"): clip.close();
34 break;
35 default: System.out.println("Not a valid response");
36 }
37 }
38 System.out.println("Byeeee!");
39 }
40}
1import java.util.Scanner;
2public class exercise30 {
3public static void main( String[] args ) {
4Scanner keyboard = new Scanner(System.in);
5int total = 0;
6boolean current;«
7System.out.print("Type in a bunch of values and I'll add them up. ");
8System.out.println("I'll stop when you type a zero.");
9while (total += current){
10System.out.print("Value: ");
11current = keyboard.nextInt();
12
13System.out.println("The total so far is: " + total);
14} while ( current != 0 );
15System.out.println("The final total is: " + total);
16} }