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 9215865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:17:51+00:00 2026-06-18T02:17:51+00:00

class SomeClass { static public void someStaticMethod(){}; } SomeClass SomeClass=new SomeClass(); SomeClass.someStaticMethod(); How to

  • 0
class SomeClass
{
    static public void someStaticMethod(){};
}

SomeClass SomeClass=new SomeClass();
SomeClass.someStaticMethod();

How to call the static method of any class where object name is same as class name?

  • 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-18T02:17:52+00:00Added an answer on June 18, 2026 at 2:17 am

    You don’t have to do anything – it will work as is (although it makes little sense to use such a confusing code).

    How ambiguous names are handled is specified in the JLS #6.5.2. In particular:

    If the AmbiguousName is a simple name, consisting of a single Identifier:

    • If the Identifier appears within the scope (§6.3) of a local variable declaration (§14.4) or parameter declaration (§8.4.1, §8.8.1, §14.20) or field declaration (§8.3) with that name, then the AmbiguousName is reclassified as an ExpressionName.
    • […]
    • Otherwise, if a type of that name is declared in the compilation unit (§7.3) containing the Identifier, either by a single-type-import declaration (§7.5.1), or by a type-import-on-demand declaration (§7.5.2), or by a single-static-import declaration (§7.5.3), or by a static-import-on-demand declaration (§7.5.4), then the AmbiguousName is reclassified as a TypeName.

    So in your case, SomeClass will be the variable you declared one line above, which has priority over types.

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

Sidebar

Related Questions

Is it legal? class SomeClass { public: static void f(); }; using SomeClass::f; Edit:
public class SomeClass{ public static void main (String[] args){ if(true) int a = 0;//
I want a magic to happen like that... class SomeClass {} public static void
When I'm testing this static method public class SomeClass { public static long someMethod(Map
So I have a class with a method as follows: public class SomeClass {
Suppose I have a class that processes some data: class SomeClass { public: void
I have the following C# class: public class SomeClass{ public string Name; public List<SomeClass>
Suppose I have this code (pseudocode) class SomeClass { class Person { public static
CA1004: Generic methods should provide type parameter public static void IfNullAndNullsAreIllegalThenThrow<T>(object value) { if
To explain: public class SomeClass { int aNumber = 0; public void changeNumber(int number){

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.