?
Solved

1 error

Posted on 2006-06-19
18
Medium Priority
?
245 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Suggested Courses
Course of the Month10 days, 6 hours left to enroll

762 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