Java student, super newb, totally stumped. Compile, no errors. Run shows nothing.
Greetings,
I am a student just starting to learn some basic Java programming and am totally stumped. I'm not even sure it's an issue with my code but I don't understand Java well enough to guess what else it might be, so I apologize if it is not my code and therefore this is the wrong forum.
Assignment is write a program that will produce the data as it shows in our book. Instructor asked that we submit one program for all the assigned "problems".
Using jGrasp, when I compile my code as below, it comes back as "operation complete" and shows no errors. So I run the thing to see if everything shows as it's supposed to and it gives the same "operation complete" message as I get when I compile and doesn't show any output. I didn't change any settings in jGrasp and it was working before, showing the output when I would run something. Hopefully, I'm making sense. Thank you for your time.
Code Java:
public class TE1_ah_ah {
public static void main (String[] args) {
}
public static void victry() {
System.out.println("////////////////////");
System.out.println("||Victory is mine!||");
System.out.println("\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\");
}
public static void spikes() {
System.out.println("\\/");
System.out.println("\\\\//");
System.out.println("\\\\\\///");
System.out.println("///\\\\\\");
System.out.println("//\\\\");
System.out.println("/\\");
}
public static void difference() {
System.out.println("What is the difference between \n a ‘ and a \"? Or between a \" and a \\\"? \n \nOne is what we see when we’re typing our program. \nThen other is what appears on the \' console.\" ");
}
public static void egg() {
System.out.println(" _______");
System.out.println(" / \\");
System.out.println("/ \\");
System.out.println("-\"-'-\"-'-\"-");
System.out.println("\\ /");
System.out.println(" \\_______/");
}
public static void eggs() {
drawTop();
drawBottom();
drawCrack();
drawTop();
drawBottom();
drawCrack();
drawBottom();
drawTop();
drawCrack();
drawBottom();
}
public static void drawTop() {
System.out.println(" _______");
System.out.println(" / \\");
System.out.println("/ \\");
}
public static void drawCrack() {
System.out.println("-\"-'-\"-'-\"-");
}
public static void drawBottom() {
System.out.println("\\ /");
System.out.println(" \\_______/");
}
public static void starFigures() {
drawRowsX();
System.out.println();
drawRowsX();
drawRows();
System.out.println();
drawStack();
drawRowsX();
}
public static void drawRowsX() {
drawRows();
System.out.println(" * * ");
System.out.println(" * ");
System.out.println(" * * ");
}
public static void drawRows() {
System.out.println("*****");
System.out.println("*****");
}
public static void drawStack() {
System.out.println(" * ");
System.out.println(" * ");
System.out.println(" * ");
}
}
Re: Java student, super newb, totally stumped. Compile, no errors. Run shows nothing.
your code is really messed up. first of all u have created so many objects but none logical printouts. Please read some info about this b4 creating smth.
Re: Java student, super newb, totally stumped. Compile, no errors. Run shows nothing.
Code Java:
public class TE1_ah_ah {
//Only whats in the MAIN method will be run
public static void main(String[] args) {
spikes(); //this will print out whats defined in the spikes method
//to print victry contents, simply type victry(); uncommented etc etc
}
public static void victry() {
System.out.println("////////////////////");
System.out.println("||Victory is mine!||");
System.out.println("\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\");
}
public static void spikes() {
System.out.println("\\/");
System.out.println("\\\\//");
System.out.println("\\\\\\///");
System.out.println("///\\\\\\");
System.out.println("//\\\\");
System.out.println("/\\");
}
public static void difference() {
System.out.println("What is the difference between \n a ‘ and a \"? Or between a \" and a \\\"? \n \nOne is what we see when we’re typing our program. \nThen other is what appears on the \' console.\" ");
}
public static void egg() {
System.out.println(" _______");
System.out.println(" / \\");
System.out.println("/ \\");
System.out.println("-\"-'-\"-'-\"-");
System.out.println("\\ /");
System.out.println(" \\_______/");
}
public static void eggs() {
drawTop();
drawBottom();
drawCrack();
drawTop();
drawBottom();
drawCrack();
drawBottom();
drawTop();
drawCrack();
drawBottom();
}
public static void drawTop() {
System.out.println(" _______");
System.out.println(" / \\");
System.out.println("/ \\");
}
public static void drawCrack() {
System.out.println("-\"-'-\"-'-\"-");
}
public static void drawBottom() {
System.out.println("\\ /");
System.out.println(" \\_______/");
}
public static void starFigures() {
drawRowsX();
System.out.println();
drawRowsX();
drawRows();
System.out.println();
drawStack();
drawRowsX();
}
public static void drawRowsX() {
drawRows();
System.out.println(" * * ");
System.out.println(" * ");
System.out.println(" * * ");
}
public static void drawRows() {
System.out.println("*****");
System.out.println("*****");
}
public static void drawStack() {
System.out.println(" * ");
System.out.println(" * ");
System.out.println(" * ");
}
}
When you post in the future, use tags to make the code readable.
Your code is fine, the reason you had no output was because you didn't specify anything to be printed.
The 'main' method of a class is what gives you results, and as it was empty, the program would run and end without displaying anything.
I've put an example back into your code which will print the contents of your spikes() method.
I suggest you read up more on Java before attempting any more programs as it will help you greatly.
Oracle offer a great tutorial:
The Java™ Tutorials