• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why wont oracle display any of my System.out.println.  RSS feed

 
Joshua Hyder
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having an issue with getting this attempted program to work. When I try to run this program in oracle, the console flickers, then it says terminated. I'm not getting any output. I believe I have made a mistake with the way I am using the class Project3StringInstrument. Below are the two classes ,which are in the same package, hat i am referring to. I am attempting to test the first class with my second class. Am I calling the methods wrong? Is there a functionality of methods and classes that I'm not aware of? Thank you for your help.

[Added code tags - see UseCodeTags for details]
 
Mansukhdeep Thind
Ranch Hand
Posts: 1163
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having an issue with getting this attempted program to work. When I try to run this program in oracle, the console flickers,....


Why are you running Java code in Oracle? Use a simple text editor like Notepad++ to write code, compile it and then run from command prompt.
 
Campbell Ritchie
Marshal
Posts: 56540
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Thank you for adding the code tags. Unfortunately, that accentuates the excessive line length in your post which makes the code difficult to read; I have broken the lines so you can see how to do it. you should not use tab characters anywhere. Set up automatic indentation and conversion of tab→4 spaces on your text editor.
The use of the word “Oracle” is a red herring. You are simply using the Oracle JVM, but you would get the same results from any JVM. You are not calling any code anywhere which prints anything You have print instructions but you never get to use them. There is a little mistake, which I am sure everybody here has made themselves (or similar) in the code to enter the loop.

That is the minor mistake. Unfortunately the rest of the code is not object‑oriented code, and you are going to hate me for what I shall say next. You should start again. You should have a String class and an Instrument class. Each String can have a name field (and maybe also frequency), but a Note class might be even better. Then the String can have a Note field. and the Note can record name and frequency.
You can have an Instrument class with a String[] and name fields. Project3StringInstrument is a bad name for the class; it is particularly bad that the 3 might refer to how many Strings or which Project. Each of the 3 classes I named should have one constructor which initialises its fields to sensible values. Remember: to initialise an array you want to initialise its individual elements, too. You don'need a count with an array, because arrays always count how many elements they can contain.
 
Stuart A. Burkett
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:You should have a String class ...

But don't call it String. That will cause lots of confusion with the standard API String class.
 
Campbell Ritchie
Marshal
Posts: 56540
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I never noticed that. Thank you.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!