Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7822153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:50:49+00:00 2026-06-02T07:50:49+00:00

I have a class defined as follows… public class df { String dt; String

  • 0

I have a class defined as follows…

public class df {
    String dt;
    String datestring;

    public String df(String dtstring) throws Exception {
        dt=dtstring;
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        Date inpdate = formatter.parse(dt);
        datestring = formatter.format(inpdate);
        Date outpdate = formatter.parse(datestring);
        SimpleDateFormat newformatter = new SimpleDateFormat("dd/MM/yyyy");
        datestring = newformatter.format(outpdate);
        return datestring;
    }
}

I create instances of this class as follows, where rsnpos.getString(1) contains a date in yyyy-MM-dd format (e.g. 2010-01-01)…

new df(rsnpos.getString(1))

During compilation, I am getting the following error…

cannot find symbol
symbol  : constructor df(java.lang.String)
location: class df

I don’t understand why this is happening, as I have defined a constructor as shown in my code. Could someone please assist me with this problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T07:50:51+00:00Added an answer on June 2, 2026 at 7:50 am

    That’s not a constructor… (constructors have an implicit “return type”, the type of the class). That has an explicit return type, and is thus not a constructor, but a normal method named df.

    Thus it is invalid when used as new df(...), which is exactly what the error message says. On the other hand, new df().df("x") would still “work” because of the default parameterless constructor and the method String df(String).

    Note the updates to change it into a constructor:

    public class df 
    {
    
      String dt;
      String datestring;
      // Remove return type (and keep matched name) to make it a constructor.
      public df(String dtstring) throws Exception
      {
        dt=dtstring;
        ...
        datestring = newformatter.format(outpdate);
        // Constructors cannot "return"
        // return datestring;
      }
    
    }
    

    Please work on variable names and naming conventions and mutability redux 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some public variables that are defined as follows: public class FieldsToMonitor {
If you have a base class defined as follows: public abstract class BaseMessageObject<T> where
I have a Software titles class which is defined as follows: public class SoftwareTitles
Let's say I have some classes defined as follows: class Security { Boolean AuthenticateUser(String
I have my JSF Handler defined in request scope as follows public class JsfHandler
I have a user control with a property defined as follows: public partial class
I have a C# class defined as follows: public class GenericItem<T> { public List<T>
Consider I have a Singleton class defined as follows. public class MySingleton implements Serializable{
I have a Student class and a StudentPool class defined as follows: public class
I have a class defined as public class viewGroups extends ListActivity Somewhere in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.