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

  • SEARCH
  • Home
  • 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 7812229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:26:24+00:00 2026-06-02T04:26:24+00:00

In java can you declare a method in a class and then either define

  • 0

In java can you declare a method in a class and then either define it later in the class or outside of the class?

I am looking for something similar to C++ where you declare it then use the :: format outside the class to define it later?

Also, not overloading the method.

  • 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-02T04:26:26+00:00Added an answer on June 2, 2026 at 4:26 am

    C++ member functions are never defined “outside of the class”. The Class_Name:: prefix puts them inside the class. They are just not in the class declaration.

    Splitting declarations and definitions is made necessary in C++ because the separate compilation model is based on text file inclusion. The detailed information about a class cannot be pulled from the compiled object file, so a condensed summary of the type information is factored out into a header file, and that must be included by all client modules of that class. Java has a more sophisticated object file format which makes it possible to get information about a class without a header file.

    Another need for declarations that arises in languages is to handle cases of mutual recursion between functions or oother forms of circular reference (for instance they are needed in the Wirth’s original Pascal language which had no support for splitting a program into separate modules). Java works out mutual recursion without requiring forward declarations. You just have to defer type checking until a full parse. Forward declarations in Pascal are not there to make mutual recursion possible, but to make it possible to compile it in one pass, whereby you can emit the code for one function before compiling the next one. (This is important when your hardware was built in 1968.)

    If you’re using a language which makes declarations unnecessary, why bother to look for a way to put them back in? It’s like continuing to eat prison food after you’ve been released. (This may be an instance of “learned helplessness”.)

    Anyway, the state of the art in type systems for decades now has been marked by designs that avoid declarations as much as possible and rely instead on type inference. Look at how many times you have to write the class name in C++ to get anything done. class myclass { public: myclass(); }; myclass::myclass() { /* constructor */ }. Four repetitions of myclass just to make a dummy class that does nothing, with a constructor that is defined outside of the class declaration.

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

Sidebar

Related Questions

In java can an instance variable and a method have the same name without
Is there anything simple Java can't do that can be done in a similar
Is it possible in Java, to declare a method with a string instead of
I'm trying to use plain old java objects(POJO)'s and regular class files where needed
In C# I can declare a static var in a class. E.g : to
During navigation of the java.lang.reflect.Method class I came across the method isBridge . Its
If we declare a method to be static, then without needing to instantiate we
Explanation/preamble In Java, if you declare an abstract class with abstract methods, e.g. public
In Java can I create a URI for a file located locally in the
A thread in java can't be restarted in Java, so I implemented a java

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.