it was excruciating, but I managed to do it. my code for the first file, "Main.java" is:
import maintu.*;
public class Main extends maintu.Maintu {
public static void main(String[] args) {
System.out.println("println");
System.out.println("I am on a different line");
System.out.print("I am print ");
System.out.print("I will be on the same line ");
System.out.println(3 + 3);
// I will be ignored
System.out.println("there is a comment after me"); // so will I
//System.out.println("I will be ignored too");
/* I will be ignored until I end
not over yet.
Now i am over*/
System.out.println("I will print though");
String variable = "you can use me to call on me for later ";
System.out.println(variable + "and I dont need quotes!");
int numVariable = 13;
System.out.print("my number is " + numVariable + ".");
String hi;
hi = "This works too!";
System.out.println(hi);
int x;
x = 10;
x = 20;
System.out.println(x);
final String finel = "I cannot change";
final int que; // I will always be empty. not 0, empty
int w = 5, y = 6, z = 50; /*you can set several variables in one line like this*/
/*you can do this as well :
int x, y, z;
x = y = z = 50;
*/
int wholenumber = 1;
float onepointone = 5.99f;
char onesinglecharacter = 'D';
boolean truefalse = true;
String unlimitedwords = "string = words";
byte onezero = -13;
short hexagecimal = -13000;
long isverylong = -4775808;
double bdoublo;
x=0;
System.out.println(maintu.Maintu.maybe);/*
while(true) {
x = x + 1;
System.out.print(x + " ");
}*/
}
}
and my code for the, as you call it "helper" file, "maintu.java" is:
package maintu;
public class Maintu {
public static String maybe = "extends";
}
the way I did it was:
write code for files
in command prompt: run javac Maintu.java
in command prompt: run javac Maintu.java
in command prompt: run javac Main.java
in command prompt: run java Main.java
command prompt output:
println
I am on a different line
I am print I will be on the same line 6
there is a comment after me
I will print though
you can use me to call on me for later and I dont need quotes!
my number is 13.This works too!
20
extends
I am using java 17