473,399 Members | 3,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Class Ambiguity problem.

dmjpro
2,476 2GB
here is my code ...

Expand|Select|Wrap|Line Numbers
  1. import org.iitkan.*;
  2. import org.iitkgp.*;
  3.  
  4. public class AnotherTest {
  5.     public static void main(String a[]){
  6.         System.out.println("Debasis ...!!!!");
  7.         Test t = new Test();
  8.     }
  9. }
  10.  
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)? ;)
May 18 '09 #1
11 2198
r035198x
13,262 8TB
Are you saying you compiled and run the code or are you asking whether the code compiles or not?
May 18 '09 #2
dmjpro
2,476 2GB
No no ... I am just asking what's the way to find out a class during compilation?
May 18 '09 #3
r035198x
13,262 8TB
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.
May 18 '09 #4
dmjpro
2,476 2GB
@r035198x
No no ..means ...
I compiled the code and ran it ;)
But i wanted to know the way of looking for a class.
May 18 '09 #5
JosAH
11,448 Expert 8TB
@dmjpro
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
May 18 '09 #6
dmjpro
2,476 2GB
So i looked at the contents of JLS 3rd edition, but i could not find it out.
May 19 '09 #7
JosAH
11,448 Expert 8TB
@dmjpro
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
May 19 '09 #8
dmjpro
2,476 2GB
:) actually to read out the whole JLS .... oops !
That's what (patience) i lack ;)
May 19 '09 #9
JosAH
11,448 Expert 8TB
@dmjpro
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
May 19 '09 #10
dmjpro
2,476 2GB
Well .. impressive! ;)
But at the beginning there are some topics which is related to Automata Theory.
So from where i should start of?
May 20 '09 #11
JosAH
11,448 Expert 8TB
@dmjpro
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
May 20 '09 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: dumboo | last post by:
hi there i m having a base class class base { ... }; and two derived class, which have inherited 'base' but the inheritance is not virtual
7
by: Richard Cavell | last post by:
#include <string> using std::string; #include <stdio.h> #include <stdlib.h> #include <gmp.h> void My Function(string ParameterOne, string ParameterTwo) { int i, j; string MyString = "hello";
18
by: Erik Arner | last post by:
Hi, I really need some help here. After upgrading to g++ 3.4 I have run into all sorts of troubles that I'm sure depends on my lack of proper understanding of C++. I would now like to get it right...
30
by: Franck PEREZ | last post by:
Hello, I'm developing a small XML marshaller and I'm facing an annoying issue. Here's some sample code: ########### My test application ############ class Foo(object): #The class I'd like to...
8
by: Gregory | last post by:
I have a question about using STL containers in C++ class public interface. Lets say that I want to return some container from class method or accept class method parameter as some container. For...
0
by: ciaran.mchale | last post by:
I used Google to find information about JAXB 2.0 and I ended up downloading a document called "The Java Architecture for XML Binding (JAXB) 2.0: Proposed Final Draft September 30, 2005". ...
6
by: silversurfer2025 | last post by:
Hello world, I seem to go from one tricky error to the other (at least tricky for me). I am using qt and another code-package where many other files are stored which I need (written by someone...
14
by: Jo | last post by:
Hi, Is there a generic way to access the (virtual) functions in the base class of a class? Like in: if (!this->Foo(something)) return(((Base*)this)->Foo(something)); // for a normal member...
14
dmjpro
by: dmjpro | last post by:
What would be the better, whether should i access the static members using class name or using Object? Which one is preferred(low-cost effective)? Today a thing stroke into my mind... Java...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.