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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:08:42+00:00 2026-06-03T02:08:42+00:00

Given the following program: class A { static int java = 42; static int

  • 0

Given the following program:

class A {
   static int java = 42;
   static int System = -1;

   public static void main(String[] args) {
      java.lang.System.out.println("Foo");
   }
}

Compiling this gives me an error saying that “int cannot be dereferenced”. The reason is obvious, but how should one handle situations like this. It is especially relevant in code-generation scenarios, where one cannot know what user code is intertwined with generated code.

In C# I would just use the “global::” namespace specifier before “java.lang”, but what do you do in Java?

  • 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-03T02:08:43+00:00Added an answer on June 3, 2026 at 2:08 am

    There is no general solution for this type of naming clash in Java. It may be upsetting to find out, but it very rarely comes up as an actual problem in practice. There are a few identifiers to avoid as member variable names, like java and com, because they are used for top-level domain names.

    There are some other potential clashes as well, which we avoid by adhering to the naming conventions — start class names with uppercase and variable names with lowercase.

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

Sidebar

Related Questions

Given the following code... class Program { static void Main(string[] args) { Foo foo
import static java.lang.System.out; import java.io.FileNotFoundException; import java.io.PrintWriter; public class ShadowingByImporting { public static void
Given the following program: import java.io.*; import java.util.*; public class GCTest { public static
I have the following program import java.util.*; public class Test { public static void
Given the following code sample: public class WeirdStuff { public static int doSomething() {
the program gives following exception: Exception in thread main java.lang.NullPointerException at myclasses.BubbleSort.run(BubbleSort.java:42) at acm.program.Program.runHook(Program.java:1519)
I tried the following code: class Program: ProgParent { public int Max(params int[] op)
Given the following code, I try to implement the public static Point operator +(int
Given the following program: using System; using System.Collections.Generic; namespace ConsoleApplication49 { using FooSpace; class
Given the following simple program: import wx class TestDraw(wx.Panel): def __init__(self,parent=None,id=-1): wx.Panel.__init__(self,parent,id,style=wx.TAB_TRAVERSAL) self.SetBackgroundColour(#FFFFFF) self.Bind(wx.EVT_PAINT,self.onPaint)

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.