Java

Moderators: zibadian
Number of threads: 7836
Number of posts: 18235

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
I wrote a program, and I need to know what to do to make it run Posted by BrianJasper on 29 Sept 2012 at 2:13 PM
So, I am trying to get this program to work, and I need some help. Here is my method in a "main" method, inside the "class" song. I am getting a few syntax errors, and I don't know what to do? Please help. Here is my code, and the listed errors after.


public class song
{
public static void main(String args[])
{
public void printSong()
{
String day="";
for(int i=1;i<=12;i++)
{
switch(i)
{
case 1:
day="first";
break;
case 2:
day="second";
break;
case 3:
day="third";
break;
case 4:
day="fourth";
break;
case 5:
day="fifth";
break;
case 6:
day="sixth";
break;
case 7:
day="seventh";
break;
case 8:
day="eighth";
break;
case 9:
day="ninth";
break;
case 10:
day="tenth";
break;
case 11:
day="eleventh";
break;
case 12:
day="twelveth";
break;
}
System.out.printf( "On the %s day of Christmas\n my true love sent to me:\n",day);
}
}
}
}


Syntax error on token "void", @ expected
printSong cannot be resolved to a type
Syntax error on token "{", delete this token
Illegal modifier for parameter day; only final is permitted
Syntax error on token "}", delete this token



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.