?
Solved

1 error

Posted on 2006-06-19
18
Medium Priority
?
247 Views
Last Modified: 2010-03-31
hi there, I am getting an error here. Could someone help me check it out. thanks. here is the program and the error respectively.

public class Calendar {
  private static Date today;
  public static Date getDate() {
    return today;
   
   
   
    static{date1 = 01012005();    
    for(int cnt = 0; cnt < var2; cnt++){      var3 += var1;
       } //end for loop    
       System.out.println("End first static init: "                                   ());  
       }; //end first static initializer block
      
  }
  public static void tock(int days) {
  }
}



this is the error...

--------------------Configuration: <Default>--------------------
C:\Calendar.java:8: illegal start of expression
    static{date1 = 01012005();    
    ^
1 error

Process completed.
0
Comment
Question by:basgen
  • 9
  • 5
  • 3
  • +1
18 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 16933341
Put the static block outside of the getDate() method
0
 
LVL 35

Expert Comment

by:girionis
ID: 16933346
public class Calendar {
  private static Date today;

  static{date1 = 01012005();    
    for(int cnt = 0; cnt < var2; cnt++){      var3 += var1;
       } //end for loop    
       System.out.println("End first static init: "                                   ());  
       }; //end first static initializer block

  public static Date getDate() {
    return today;
   
     
     
  }
  public static void tock(int days) {
  }
}
0
 
LVL 35

Expert Comment

by:girionis
ID: 16933352
BTW you will need to declare the "varx", the "date1" and the "cnt" variables.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:basgen
ID: 16933365
hmm i dont get you...how does the varx work? and the date1 and cnt?
0
 
LVL 35

Expert Comment

by:girionis
ID: 16933397
You need to declare these variable somewhere in order to use them, otehrwise you will be getting error messages. Have a look here for more info: http://java.sun.com/docs/books/tutorial/java/javaOO/variables.html
0
 

Author Comment

by:basgen
ID: 16933403
okie noted but where does these error msges go?
0
 
LVL 35

Accepted Solution

by:
girionis earned 2000 total points
ID: 16933410
If you compile the application you will see them in the console.
0
 

Expert Comment

by:Priestex
ID: 16933411
Is this a typing mistake or do you really dont have a closing bracket after the "return today;" statement?
0
 

Author Comment

by:basgen
ID: 16933423
okie, where does the class files go?
0
 
LVL 35

Expert Comment

by:girionis
ID: 16933436
I think you should start from the very basic: http://java.sun.com/docs/books/tutorial/getStarted/cupojava/index.html
0
 
LVL 35

Expert Comment

by:girionis
ID: 16933437
> Is this a typing mistake or do you really dont have a closing bracket after the "return today;" statement?

There is if you move the static initializer outside the method.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16933551
>> System.out.println("End first static init: "                                   ());  

Remove the extra () there.
0
 

Author Comment

by:basgen
ID: 16935052
does not seem to work la...the static is a prob still
0
 
LVL 35

Expert Comment

by:girionis
ID: 16935115
The static is fine, you are probably getting another error. Please post it.
0
 

Author Comment

by:basgen
ID: 16935504
okie..do u have an email address? ill send u the questions..u have a look.think that wld be better
0
 
LVL 35

Expert Comment

by:girionis
ID: 16935524
Sorry, not allowed ot help via e-mail, please post here. I need

a) the source code of the file where the error occurs
b) The error messages you are getting when you try to compile the java file
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16939872
>> }; //end first static initializer block

The semi-colon there is not required.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16941159
What was the problem and what was the solution?
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month13 days, 22 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question