I am a first year comp sci student and going through my first round of textbook problems, all dealing with the System.out.println method (no, im not looking for help on homework problems. i've satisfied (as far as i know right now) the requirements of the problem, am just looking to gain some extra information).
The first problem asked me to write a program that would output this:
//////////////////////
|| Victory is mine! ||
\\\\\\\\\\\\\\\\\\\\\\
This was no problem. I wrote the following code:`
public class Stewie {
public static void main(String[] args) {
line();
qoute();
line2();
}
public static void line() {
System.out.println("//////////////////////");
}
public static void qoute() {
System.out.println("|| Victory is mine! ||");
}
public static void line2() {
System.out.println("\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\");
}
}`
Later in the text, it asks me to write a program that prints the above figure 5 times in a row. This is also not a problem, I just rewrote the code from the first problem, like this:
/*
*/
public class Stewie2 {
public static void main(String[] args){
newStewie();
newStewie();
newStewie();
newStewie();
newStewie();
}
public static void newStewie() {
line();
qoute();
line2();
}
public static void line(){
System.out.println("//////////////////////");
}
public static void qoute(){
System.out.println("|| Victory is mine! ||");
}
public static void line2() {
System.out.println("\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\");
}
}
That's all good and well, but I'd like to know how to import class Stewie from the first problem so I could use that in the second one without having to rewrite all the code. Can anyone help me out??
edit:re:importing a custom java class. I saw this before posting, but probably do not know enough about programming for it to be helpful to me at the moment. thank you though.