Static Import question

It is a very easy (down to earth) question.
Are static imports of methods having the same name as
Object methods forbidden?public class StaticUse1 { 
  public static boolean equals(StaticUse1 su1,StaticUse1 su2) {
    return true;
  public static boolean equal(StaticUse1 su1,StaticUse1 su2) {
    return false;
}An import somewhere else:import static apackage.StaticUse1.*;
public class Test {
  public static void main(String[] args) {
    //System.out.println(equals(new StaticUse1(),new StaticUse1()));  // error
    System.out.println(equal(new StaticUse1(),new StaticUse1()));
}Compiler complains about ... equals(java.lang.Object) ...

Such static imports are allowed, but they won't work because of the scoping rules of the language. The equals(Object) for the current class always shadow such methods from the static import.

Similar Messages

  • Static imports in 1.5

    same static variable and same static method exists in two diffrent classes, while importing these two in my own implementation class follwing different output is coming why? Using j2se version1.5
    while using variable imports like
    import static package.Class1.variable1;
    import static package.Class2.variable1;
    //giving compilation errros
    while using method imports like
    import static package.Class1.method1;
    import static package.Class2.method1;
    //it is not giving any compilation error.
    Can anyone explain?

    >
    ah ok, when i wrote "Clearly" above i was assuming
    that the spec. when it does arrive (or when i can find
    it..) will disallow static imports of same signature
    methods (or possibly even just same named methods?) -
    and clearly any contravention of the spec should be
    reported to the userIf the spec says is should do something then it should do that.
    >
    on the other hand, the more the compiler can do the
    better since its a single point used by lots of
    people, so any small extra only has to be done once
    and is multiplied in the payoff - any individual
    trivial error message or warning might be
    questionable, but if lots are done then it saves time
    I doubt that a lot of people are going to be attempting to apply static imports to the same named item.
    not completely the same things, but i like the jikes
    feature where it says something like "it look like
    you're trying to invoke <SOME API METHOD> - this
    doesn't exist but a similar method does with
    signature: ... "
    I suspect that happens and is going to continue to happen far more frequently than duplicate static imports.
    And of course a compiler can add additional things like that. But that is rather different than suggesting that it is required.
    when a case is left in the grey area then at the very
    least a dozen developers will come across it and
    because of the lack of some text saying ERROR will
    start to question themselves - i don't see this as
    pandering to the developers laziness
    And yet none of the compilers warn against the "i = i++" construct.
    i've not verified this, and also the lang. spec does
    not seem to have been updated for 1.5???
    it sounds like the compiler should just complain in
    both cases?Yes but given that neither has been used I suspect
    that it will complain once they are used. If it
    doesn't then that is a bug.hm, a similar piece of code
    import java.util.List; import java.awt.List;
    complains immediately if you try to compile it - i guess this
    isn't that important but i like the
    complain-loudly-and-early approach - i think they also
    possibly made unused imports or duplicate imports
    errors or warnings for 1.5?Could be. However, the spec itself drags significantly behind the additional material. For example note that the 'current' spec doesn't have assert. So tracking down what should really be in the spec can be somewhat complicated.
    Note also that I haven't really seen the OP clarify that they expect an error for both cases rather than that they expect that no error at all should show up (because they really want to use both.) And although the first is nice the second is clearly wrong. Hopefully that point is clear.

  • "static import" construct?

    Hello,
    in a recent Java Live session (http://developer.java.sun.com/developer/community/chat/JavaLive/2002/jl0212.html), respected Joshua Bloch speaks about a "static import construct" that should help clarifying the way constants are defined and used. According to the context, I assume it would be a facility enabling to "import somepackage.someclass.someFinalField;" so as to use "someFinalField" as a shortcut.
    I found nothing published about this construct on Sun's site (bug DB, fora, articles,...).
    Do you have a link about this potential future language feature?
    And is its purpose wider than constants shortcuts (not worth the effort, I deem)?
    Jerome

    Since no-one replied, I'll answer my own question and assign all the cyber-dollars to myself ;-)
    Hello,
    in a recent Java Live session
    (http://developer.java.sun.com/developer/community/chat
    JavaLive/2002/jl0212.html), respected Joshua Bloch
    speaks about a "static import construct" that should
    help clarifying the way constants are defined and
    used. According to the context, I assume it would be a
    facility enabling to "import
    somepackage.someclass.someFinalField;" so as to use
    "someFinalField" as a shortcut.
    I found nothing published about this construct (...).
    Do you have a link about this potential future
    language feature?This topic has been publicez recently as part of JSR-201, which answers my question.
    See http://jcp.org/aboutJava/communityprocess/jsr/tiger/static-import.html for reference.
    Jerome

  • Alpha compuler cant compile enums or static imports?!?

    Pardon me if this is the wrong place to ask this question but I couldnt find any forums specific to CAP program members:
    When trying to compile enums and static imports that work with the public prototype compiler, I get the following errors:
    C:\dev\hcj\tiger\src>c:\j2sdk1.5.0\bin\javac -version oreilly/hcj/tiger/*.java
    javac 1.5.0-beta
    oreilly/hcj/tiger/EnumAttach.java:18: 'class' or 'interface' expected
    public abstract enum EnumAttach {
                    ^
    oreilly/hcj/tiger/EnumAttach.java:35: 'class' or 'interface' expected
    ^
    oreilly/hcj/tiger/ErrorLevel.java:20: 'class' or 'interface' expected
    public enum ErrorLevel {
           ^
    oreilly/hcj/tiger/ErrorLevel.java:31: 'class' or 'interface' expected
    ^
    oreilly/hcj/tiger/ForEach.java:49: ';' expected
                    for (String person: importantPeople) {
                                      ^
    oreilly/hcj/tiger/ForEach.java:55: illegal start of expression
            ^
    oreilly/hcj/tiger/ForEach.java:81: ';' expected
                    for (String person: people) {
                                      ^
    oreilly/hcj/tiger/ForEach.java:87: illegal start of expression
            ^
    oreilly/hcj/tiger/StaticImports.java:15: <identifier> expected
    import static StatusColors.*;
           ^
    oreilly/hcj/tiger/StaticImports.java:15: '.' expected
    import static StatusColors.*;
                                ^
    oreilly/hcj/tiger/StaticImports.java:16: <identifier> expected
    import static java.lang.Math.*.
           ^
    oreilly/hcj/tiger/StaticImports.java:21: '.' expected
    public class StaticImports {
           ^
    12 errorsIs there something I am doing wrong or is this known bug?

    Use the compiler flag -source 1.5

  • Static Imports

    What is the advantage of static imports? .........

    They allow you to refer to static members without having to fully qualify them. As you'll see, they should be used sparingly. Read more here:
    [1] http://java.sun.com/j2se/1.5.0/docs/guide/language/static-import.html
    [2] http://www.deitel.com/articles/java_tutorials/20060211/
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    ----------------------------------------------------------------

  • How to import questions into Captivate 4 from a delimited file

    I'm looking
    a way to import questions from a delimited text file (or excel spreadsheet)
    into captivate.
    All the questions are simple multiple choice, single answer, four selections per question.
    I have hundreds - I'd hate to have to retype them all in one at a time.
    Thanks in advance
    -Joan

    Does anyone know if this is a feature in Captivate 5. 
    Other things I would really like to see in Captivate 5.
    Importing and Exporting the graded quiz/test content out of captivate into another
    application/ form.  Such as xml, tab delimited, excel spreadsheet,
    Adobe pdf, Word document or another format.  Our current content
    developement systems allows us to (when publishing) do this.
    1> exclude questions from the Published content
         (exclude section questions, or final test content)
    2> produce different test versions from question banks
    3> Produce a PDF paper test for when we want to train in a classroom setting
    4> Select which questions we want to produce
    5> Import questions from a pre-defined format.  To note: when we do this the system also makes us define a unique interaction id so that the import will update existing questions.
    I know this will NOT work for some of the more sophisticated questions, But for the simple Mulitple choice, true/false, fill in the blank.  etc..
    THIS WOULD BE A GREAT FEATURE..
    It would also be NICE TO HAVE THE abiliy to PROFILE versions of the SAME Course WITH OUT REPRODUCING / DUPLICATING / REPEATING THE  ENTIRE COURSE PRESENTATION.
    Such as
    "INSTRUCTOR TAUGHT TRAINING"
    "WEB TRAINING"
    "PAPER TEST A"
    "PAPER TEST B"
    ETC...
    LASTLY: if we can not export the QUIZ content.  Can an excel spreadsheet LIKE INTERFACE be used to edit certain aspects of the questions.
    Such as the InteractionId which is sent to the LMS ('cmi.interactions.0.id').  My developer team says it is real difficult and time consuming
    to track down interactionIds and then maintain them in a perfect way.
    Thanks,
    Doug Lubey of Louisiana
    www.douglubey.com

  • Can anyone explain this to me, please. It's a static section question.

    Can anyone explain this to me, please. It's a static section question.
    I came across the following style of programming recently and I would like to know what the Static section is actually doing in the class. Thx.
    Here is the code.
    public class ClassA {
         private static Hashtable ClassAList = new Hashtable();
         private ClassB cB;
         private Vector goodLink;
         private Hashtable classCList;
         static
              ClassA cA = new ClassA();
              ClassAList.put("whatever", cA);
         public static ClassA getClassA()
              return (ClassA) ClassAList.get("whatever");

    hi,
    The static section shall be loaded before it's constructor is called. (i.e at the time of loading the class). Therefore making it available for any other objects to call.
    hope this clarifies ur question
    prasanna

  • Static import from SE5 (Ex 16 on p. 91 in Thinking in Java Edn 4 by Eckel)

    The following line of code is underlined:
    import static net.mindview.util.Print.*;with this error displayed:
    static import declarations are not supported in -source 1.4
    (try -source 1.5 to enable static import declarations).
    My Path variable contains these:
    C:\Program Files\Java\jdk1.6.0\bin;C:\Program Files\Java\jre1.6.0\bin;D:\java\TIJ4\code
    D:\java\TIJ4\code is the root folder for net.mindview.util.Print.
    JRE1.6 and JDK1.6 are installed.
    I also have:
    i.e. a dot, in my CLASSPATH variable.
    This is from the 4th edn of Thinking in Java by Bruce Eckel. If you are or have been through this stuff I would really appreciate it if we could meet on Skype every now and then to talk about issues like the one described above.
    Thanks for your help,
    b

    Now same code is underlined:
    import static net.mindview.util.Print.*;but with this error message:
    package net.mindview.util does not exist
    However it is mapped like this:
    D:\java\TIJ4\code\net\mindview etc..
    So, I have put this in to the Path variable:
    D:\java\TIJ4\code because it is the root folder of net.mindview.util.
    Is there something else I should do? Is is ok to have a non C directory in the Path variable?
    Thanks for any help,
    B

  • Cannot static import in JSP (WebLogic 10.3)

    I am facing a problem with the use of 'static import' in JSP. This is on WebLogic 10.3. Please help/advise.
    Running weblogic.jspc results in the following error:+
    $ java weblogic.jspc -verboseJspc -keepgenerated -d /tmp/jsp WEB-INF/jspf/fragment.jspf
    \[jspc\] Overriding descriptor option 'keepgenerated' with value specified on command-line 'true'
    \[jspc\] Compiling /WEB-INF/jspf/fragment.jspf
    jspc failed with errors :weblogic.servlet.jsp.CompilationException: fragment.jspf:6:17: Syntax error on token "static", Identifier expected after this token
    <%@page import="static java.util.Collections.EMPTY_LIST" %>
    ^-------------------------------------^
    fragment.jspf:6:17: The import java.util.Collections.EMPTY_LIST cannot be resolved
    <%@page import="static java.util.Collections.EMPTY_LIST" %>
    ^-------------------------------------^
    The generated Java file is not correct; the static import is split into multiple imports+
    $ head /tmp/jsp/jsp_servlet/_web_45_inf/_jspf/__fragment_jspf.java
    package jsp_servlet._web_45_inf._jspf;
    import java.lang.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.jsp.*;
    import static;
    import java.util.Collections.EMPTY_LIST;
    public final class __fragment_jspf extends weblogic.servlet.jsp.JspBase implements weblogic.servlet.jsp.StaleIndicator {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    I'm not sure that JSPC supports static imports, I would open a support case to get clarification.

  • BUG: JDeveloper code editor shows valid static import call as error

    I've noticed what appears to be a bug in the JDeveloper code validator when dealing with static imports.
    The following classes demonstrate the problem:
    package test;
    public class Parent {
      public static void parentMethod() {
        System.out.println("called parentMethod.");
    package test;
    public class Child extends Parent {
      public static void childMethod() {
        System.out.println("called childMethod.");
    package test;
    import static test.Child.*;
    public class StaticInheritanceTest {
      public static void main(String[] args) {
        Child.childMethod();
        Child.parentMethod();
        childMethod();
        parentMethod();  //<-- this line is highlighted as an error
    }Notice how on lines 7 and 8 of StaticInheritanceTest, the code validator does recognise that both parentMethod and childMethod are static methods of the Child class.
    Since 'Child' has been statically imported, then parentMethod should be available. Although parentMethod is presented as an 'auto-suggest' at line 11 in StaticInheritanceTest, when you try to call it the code editor shows the call as an error and the Ctrl-Click (to drill down into the method) doesn't work.
    When I run the class, it compiles successfully and runs with the following output:
    called childMethod.
    called parentMethod.
    called childMethod.
    called parentMethod.This might seem like an obscure and theoretical problem, but I've hit this whilst using Mockito, which uses exactly this kind of inherited static method to provide matchers.

    Hi,
    thanks. Will file a bug. This seems to be a designtime only issue that does not present a show stopper.
    Frank

  • MEGA180 Important Questions

    I have my MEGA180 on order but I already have some important questions:
    1) This unit provides dual vga outputs. If I install my own AGP 8x card, will the VGA2 output still work? I read in the manual that installing an AGP card will disable VGA1 (default) but it doesn't say anything about the 2nd VGA output connector. I require 2 outputs since I will be connecting to an LCD and my HDTV monitor (using a VGA to Component Video Transcoder)
    2) Will there be performance hits by using the two vga outputs at the same time?
    3) The on-board video card doesn't have any video memory. It will use your existing DDR memory. I will have 512Meg Dual Channel Memory. What kind of performance I can expect from the built-in video card (NVidia NForce Crush18) compared to other AGP cards on the market?
    Thanks for your help!
    Sly

    Though I can not provide you with answers specific to the Mega 180, I can give you some more info.
    1) No. As soon as you install an AGP card, the onboard video will be fully disabled from within the BIOS. This is an nForce2 chipset setting. So make sure to get an AGP card with 2xVGA (as most cards have nowadays).
    2) No or not much. Using an nForce2 MoBo myself I haven't encountered performance loss using both VGA outputs.
    3) There's no way to compare the onboard video to an AGP card. AGP cards will have a far out better perfomance then the onboard video. But compared to other onboard video solutions around, like Xtreme Graphics, the nForce solution is far better and has far better performance.
    It all depends on what you will be doing with the MegaPC. If you're a gamer, get an AGP card. If you want to use it as an HTPC, keep with the onboard nForce2 solution. There's no need for extra here since the nForce2 chipset is great. Onboard sound from this chipset is also great. Try it out before spending $ on an AGP card you don't need.
    Hope this helped a bit.
    roma

  • E-Recruiting important questions

    I'm implementing the E-Recruiting and I have two important questions for this Project:
    1 - The business want to capture mobility (willingness to relocate / travel) at the time of position application. Is there a standard field for store this information?
    2 - Recruitment would like to be informed about a critical process, in others words, the requisition doesnu2019t compete with other priorities. How can I handle this situation?
    Thanks in advance!!!
    Sivani

    Hi Sivani,
    Questionnaire answers are stored in IT5141.  They are visible to the Recruiters when viewing the Candidates and can be used in rankings.  You can also decide for which positions this questionnaire would be required and which not. 
    Do not see a standard field to create a priority when creating a Requisition.  We added many fields, such as "eligibility for employee referral", so it can be added.  However, letting managers set the priorities could be a problem with each manager thinking his/her opening is most important. 
    Paul

  • Server Specs for a 11.1.1.3 Install Important questions.

    I've put together some specifications for a Development Server & Production Server, any comments appreciated. I hope this post acts as a good reference sample for anybody else out there looking to implement a Hyperion Planning.
    Client Tier: (2 developers)
    Windows
    8 GB RAM
    Dual Core Processor
    Components: EAS client, Smart View, Excel Add-in
    Web Tier:
    HTTP Web and J2EE Servers:
    Windows + (not sure which version would be best here, any ideas appreciated)+
    Processor: 4 x 3 GHZ, 64 bit
    RAM: 8GB
    Hard Drive: 32 GB
    Components: Foundation: HSS, Workspace, Planning, Web Applications: EAS, Financial Reporting, Web Analysis, Planning,
    Services Tier:
    Server1:
    Windows (2003 SP1, R2)
    Processor: 4 x 3 GHZ 64 bit
    RAM: 16 GB
    Disk: 32GB
    Components: Essbase Server 64 bit
    Server2:
    Windows (2003, SP1 R2)
    Processor: 2 x3 Ghz
    RAM: 8GB
    Hard Drive: 32GB
    Components: Reporting & analysis, Financial Reporting Print Services, ODI
    Server 3:
    Windows (2003, SP1 R2)
    Processor: 2 x3 Ghz 64 bit
    RAM: 8GB
    Hard Drive: 32GB
    Components: FDM
    Database Tier:
    4 x 3 GHZ - 8 GB RAM
    DISK: 100GB RDBMS
    200GB Essbase Storage
    The specifications will be similar for the production for abotu 25 - 30 users (10 concurrent), with RAM being a little bumped up.
    One important question: I might need guidance on installing 32 bit planning or FDM on the 64 bit server - any known issues with this? Also any known issues with 64 bit Essbase working with 32 bit Planning?
    Edited by: EssbaseApprentice on Sep 30, 2010 10:04 AM

    obviously its hard to comment on whether it is the perfect spec for your environment, it looks alright to me, it is not under spec.
    For the web tier as you are running reporting and analysis and the other machines are windows based personally I would stick with windows 2003.
    Is there any reason why you have one machine dedicated just to FDM, seems a bit of an overkill just for one product, it may be worth combining services server 2 with FDM, just a suggestion though
    John
    http://john-goodwin.blogspot.com/

  • Important Questions to ask when developing in Workflow

    Hello All,
      I have two questions.
      I am not a Workflow developer, but I've been asked to find out information about creating a Workflow process.
    Here is what <b>I</b> need to know: What are important questions to ask the end-user when creating a workflow. What needs to be taken into consideration?
    Here is an example of the kind of thing we need to do:
    Send an email on a weekly basis to different Project Managers a Summary of Project Charges = (maybe CN41?)
    Each Project Manager will have different requirements, so  I guess one question will be: "What info do you want from this report?". What else do I need to know?
    My second question is this: I should be able to output this as an Excel, correct? How much can I customize this? I haven't done much SAP -> Excel work. Only when I go to System -> List -> Save -> Local File ->Spreadsheet.
    Thanks for the help.
    Don Fields

    Hello Don!
    WF is quite a complex topic and someone could write a book to answer your questions - actually there is already a good book available -> check: Practical Workflow for SAP
    http://www.sap-press.com/product.cfm?account=&product=H950
    Looking at your example their might not even be a need for a workflow but rather a job that runs periodically to send the required information via email to project managers.
    Workflow is mostly used if user actions are required e.g. confirm, approve, reject a request or notifications need to be sent to someone after an event or user action occured.
    Check this link for getting more information on how to download data to excel:
    http://www.sapdevelopment.co.uk/reporting/email/attach_xls.htm
    Harald

  • Adobe Captivate Help | Import questions from GIFT format files (Cp 7)

    This question was posted in response to the following article: http://helpx.adobe.com/captivate/using/import-questions-gift-format-files.html

    Hi there,
    Captivate 7 doesn't support tags during GIFT import. So you won’t be able to import Images, links etc. as part of GIFT Import.
    Thanks,
    Nimmy Sukumaran.

Maybe you are looking for

  • Apache mod_rewrite and mod_wl together

    Hi everybody, I'm having a problem with apache (1.3.27 on linux) mod_rewrite and mod_wl. The httpd.conf looks like this: RewriteEngine on RewriteCond %{QUERY_STRING} Id=100 RewriteRule ^/dynamic/tops$ /static/100.html [P] <Location /dynamic> SetHandl

  • Install iTunes 8.2.1 on my PowerPC G5

    I wish to install iTunes 8.2.1 on my PowerPC G5. I know it's an old version. However, I'm wary to install iTunes 9 or 10 for various reason: compatibility with an iPhone 3 and problems syncing old music with iStore. I've upgraded iTunes before and ha

  • Xp SP3 and PDF in page

    I am aware of the arguments against embedding PDFs in pages, but need to do this for a number of sites I manage. Up to the installation of XP SP3 on my system the other day, all seemed to work fine using <embed> inside <object> to cater for IE and ot

  • How to restore an ipod touch

    Hey there! I have one ipod touch that I've found at the bus while travelling, I'm already an user of iphone and ipod touch my self, I've posted signs asking if any one lost it but didn't say the color of the protection cover just to be sure the owner

  • Cannon FS30 to MBP works, but not to MB

    We have a MacBook Pro and a MacBook. When we connect our Cannon FS30 to the MacBook Pro, iMovie and iPhoto recognizes it right away and we can import movies and photos. However, when we hook up the camera to the MacBook, only iPhoto recognizes the ca