Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

declaring arrays  RSS feed

 
Dave Kairys
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to Java, but not to programming. I want to declare an array as follows: Month1 [ ] Name = new Month1 [12];
Upon compiling, it states that the symbol cannot be found. Here is the code from the original class file:
class Month1{
int Days;
String Name;
I want to following to display, repeating 12x:
January has 31 days
February has 28 days
etc for the rest of the months

Any help is appreciated! Thanks!
 
Khan Malamir
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your array declaration looks correct(except for the uppercase variable names that are not Java-conventional).
Are you sure you have compiled the Month1 class? Is it on the class path when you compile the client class? What commands do you use to compile the classes and what is the package structure?
 
Norm Radder
Ranch Foreman
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it states that the symbol cannot be found.

Could you copy and post the FULL error message along with the source that causes the error? Otherwise we're just guessing!
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Norm Radder:

Could you copy and post the FULL error message along with the source that causes the error? Otherwise we're just guessing!


Agreed. Paraphrasing error messages loses crucial information that we need to help you.

Layne
 
Dave Kairys
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help and suggestions. I figured it out in the interim. Uppercase declaration is a carry-over from .NET, that's why it is in the Java code.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dave Kairys:
Thanks for your help and suggestions. I figured it out in the interim. Uppercase declaration is a carry-over from .NET, that's why it is in the Java code.


You might be interested in Sun's suggested Code Conventions for Java. If you follow these, your code will be easily understood by other Java programmers when you ask for help. It will also help you more easily understand your own code.

Layne
 
Dave Kairys
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I will take a look at it and follow the suggestions from here on out. One thing I can say about the Java group- You guys are truly out to help the other members. I posted a question on the MSDN site a few months ago and am still waiting for a reply! I found it unbelievable that when I posted a question, there was an extremely helpful response within the hour! Kudos to all of you!

Thanks again!
Dave
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!