Class Ambiguity problem.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    Class Ambiguity problem.

    here is my code ...

    Code:
    import org.iitkan.*;
    import org.iitkgp.*;
    
    public class AnotherTest {
        public static void main(String a[]){
            System.out.println("Debasis ...!!!!");
            Test t = new Test();
        }
    }
    The Test class exists in three packages .. org.iitkan, org.iitkgp and the default package. If i run this program then it runs well. How a class gets looked into the packages?
    Here what's happening, first compiler look into the default package if not then ambiguity error flashed(if a class found in two imported different packages)? ;)
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Are you saying you compiled and run the code or are you asking whether the code compiles or not?

    Comment

    • dmjpro
      Top Contributor
      • Jan 2007
      • 2476

      #3
      No no ... I am just asking what's the way to find out a class during compilation?

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        I really can't make sense of the question.
        If you want to know whether the code compiles or not, then just try it and see what will happen.

        Comment

        • dmjpro
          Top Contributor
          • Jan 2007
          • 2476

          #5
          Originally posted by r035198x
          I really can't make sense of the question.
          If you want to know whether the code compiles or not, then just try it and see what will happen.
          No no ..means ...
          I compiled the code and ran it ;)
          But i wanted to know the way of looking for a class.

          Comment

          • JosAH
            Recognized Expert MVP
            • Mar 2007
            • 11453

            #6
            Originally posted by dmjpro
            No no ... I am just asking what's the way to find out a class during compilation?
            A class is visible if it is an element of the class (to be compiled) from the same package or, if it has been made visible explicitly by an import statement. If more than one class with the same simple name is visible the simple class name is ambiguous and the compiler emits an error message. Read the JLS for a more detailed description.

            kind regards,

            Jos

            Comment

            • dmjpro
              Top Contributor
              • Jan 2007
              • 2476

              #7
              So i looked at the contents of JLS 3rd edition, but i could not find it out.

              Comment

              • JosAH
                Recognized Expert MVP
                • Mar 2007
                • 11453

                #8
                Originally posted by dmjpro
                So i looked at the contents of JLS 3rd edition, but i could not find it out.
                Well, that's easy then: give up, don't read the JLS and take my terse explanation for granted. The JLS is not a novel, i.e. you can't just 'look at the contents' and understand what it's all about; it takes reading and understanding. That's how language definitions are written.

                kind regards,

                Jos

                Comment

                • dmjpro
                  Top Contributor
                  • Jan 2007
                  • 2476

                  #9
                  :) actually to read out the whole JLS .... oops !
                  That's what (patience) i lack ;)

                  Comment

                  • JosAH
                    Recognized Expert MVP
                    • Mar 2007
                    • 11453

                    #10
                    Originally posted by dmjpro
                    :) actually to read out the whole JLS .... oops !
                    That's what (patience) i lack ;)
                    Well, you'd better give it a try, it is worth it; reading the JLS is not like browsing, skimming through something, copy and paste a few examples and have some half understood code up and running after some hacking.

                    A JLS is the definition of a language and it has to be exact in its wordings; it was (most likely) written by some language lawyers. Read it as such. Believe me, the JLS reads like a simple novel compared to the ANSI/ISO texts for the C OR C++ programming languages.

                    kind regards,

                    Jos

                    Comment

                    • dmjpro
                      Top Contributor
                      • Jan 2007
                      • 2476

                      #11
                      Well .. impressive! ;)
                      But at the beginning there are some topics which is related to Automata Theory.
                      So from where i should start of?

                      Comment

                      • JosAH
                        Recognized Expert MVP
                        • Mar 2007
                        • 11453

                        #12
                        Originally posted by dmjpro
                        Well .. impressive! ;)
                        But at the beginning there are some topics which is related to Automata Theory.
                        So from where i should start of?
                        They talk about grammars: the lexical grammar that defines the sequence of characters that make up valid tokens and the syntactical grammar that defines the syntactically valid sequences of tokens that make up valid program fragments. If grammars are not your cup of tea feel free to skip those sections.

                        kind regards,

                        Jos

                        Comment

                        Working...