Newbie question about import statement

Lets say for example I have a class A and a class B.
Then lets say I import class A into class B.
If I instantiate some objects and methods in class A
Will I be able to access them in class B.
Thanks gemann

Imports are used to import classed from another package.
Conside a package named package1 and class named A in it.
package package1;
public class A{
  //public method
  public void publicmethod() {}
  //private method
  private void privatemethod() {}
  //default method
  void defaultmethod(){}
  //protected method
  void portectedmethod(){}
}Now conside another package named package2 having a class B.. and you want to make an object of class A and want to call its method..
package package2;
import  package1.A;  // or import package1.*   it imoprts every class in this package
class B{
B(){
A a=new A() ; // possible since we imported it..
a.publicmethod() // possible since it is public method
a.defaultmethod()// Not possible. since it is a this is in a different package
a.protectedmethod()// Not possible since this is in  a different package, and this is not a derived a derived class of B
a.privatemethod() // Not possible since it is private
}Hope it is clear now..
appu

Similar Messages

  • Question about import statements

    Why is it that I must have the import statement on the
    same frame
    and same layer
    as the AS code that utilizes the Class that I am importing?
    At least that is how it appears.

    Because that is how it works.
    Remember, import doesn't actually "import" anything. It is
    just a shortcut so you don't have to type the whole package name
    every time you use the coded in your example.
    It is actually kind of nice when you come back to code later
    or if you open somebody else's code (that you have to update or
    change) and to see at the top, "Oh, this bit of code has a reliance
    on class blah.blah.Yadda." In a way it kind of helps enforce a bit
    of good coding practice.

  • Java Newbie Question - the import statement

    Hi Geeks,
    I have a problem for importing a java .class in my project. This latter is named "Tedetis_New". Inside it, I created a "src" folder containing all the source code of the application. I import a jar file inside the parent directory of "src" (i.e. at the root of the project). Inside this jar archive, two classes (.class files) are not placed inside a package (default package according to eclipse), let's name one toto.class. So when I want to import toto.class from a file inside the src directory I simply do "import toto.class" but this statement doesn't work ! I don't manage to import my toto.class so ... what do you propose for this ?
    Thanks.

    Don't use the "default" class for anything serious;
    you can't import such a class.Er, package maybe?Yes, I was editing my reply while you replied to my reply so I couldn't
    edit my little blooper in my reply anymore; thank you very much Sir ;-)
    kind regards,
    JosI entered that response as quickly as I could, for just that reason. I
    thought you might notice and try to correct it, and I wanted to preserve
    your fuckupus maximus for all eternity.
    Everyone gather round and taunt Jos! Wave your private parts at his
    auntie! Fart in his general direction!
    Now, aren't you glad you didn't say "Jehovah"?I already knew that you were the one who invented amiability ;-)
    kind regards,
    Jehov^H^H^H^Hos

  • Newbie question about importing articles

    Sorry for the most basic of questions but I cant seem to find the answer. If I am importing an Indesign document that has more than one page into a single edition folio do I have to break out each page and import one at a time or will DPS allow me to import say, 5 pages at a time? Does each page have to be its own document with appropriate links or can I bring in multiple pages and common links from the same document? Thanks in advance- I suspect it is one at a time but that can become cumbersome for a long article, especially when you are working with master pages and would like to adjust common elements without having multiple InDesign docs.

    Each article can be as many pages as you want it to be. You can import as
    many articles as you want as long as they're in the right folders.
    You can download Bob Bringhurst's DPS Tips app from the app store and if
    you'd like you can watch my DPS Essential Training on Lynda.com. Here's a
    link the announcement of the course which contains a link for a free on week
    trial:
    http://boblevine.us/my-first-lynda-com-title-adobe-digital-publishing-suite-
    essential-training-is-live/

  • Question about import statement

    Hi all!
    I was wondering if a line like this:
    import java.io.*imports all classes from java.io or just the classes needed by your program (the classes you actually using in your code). Can anyone give me a little hint on that?

    The way I understand it is that it simply makes the
    classes in that package 'visible'. This means that you
    don't have to type the fully qualified name each timeOh, yeah. I was thinking too much in C and it's #include.
    Thanks :-)

  • Newbie question about switch statement

    Lets say you have a loop and inside the loop you have a switch statement, how do you BREAK out of the outer loop?
    for (i=0....) {
    switch {
    case 11:
    .... some stuff
    break; <==== HOW DO I BREAK OUT OF THE for loop here?

    In standard C and standard C++ the break statement terminates the nearest enclosing loop and only that loop; i.e. control transfers to the first statement following the loop. I think there are C or C++ extensions that allow loop tags which may be used with a break to specify which loop to drop through, but I don't think these are supported by gcc, and they would certainly be very non-portable.
    There are several common ways to drop out of one or more outer loops. In many cases, there's nothing else in the loop following the switch so you can simply write
    switch (condition) {
    default:
    case 0:
    break;
    // other case statements here
    break;
    Else you can declare a loop control var and use the continue statement like this:
    for (i=0; i<jMax && !bDone; i++) {
    switch (condition) {
    default:
    case 0:
    bDone++; continue;
    // other case statements
    If you need to escape several loops and/or don't want to use loop control vars, you might consider structuring the code so you can use return to terminate the entire function. In the worst case of a very complex structure that you don't know how to simplify with a helper function, you can always resort to a goto:
    switch (condition) {
    default:
    case 0:
    goto escape;
    // other case statements here
    // remainder of code inside nested loops here
    escape: <first statement following the outermost loop>;
    Note that the statement following the escape label is always executed; i.e. when execution skips the goto it's as if the statement following escape was unlabeled. Use goto sparingly of course, since it's an artifact of unstructured programming. But when you really need a goto, it can make your code much easier to maintain.

  • Newbie question about imported video

    Hi,
    I am trying to embed a movie into the timeline. I want it to
    play once and then have the page redirect to another page afterward
    (I am trying to create a splash screen). I don't want the movie
    player which is why I have chosen to embed it.
    I can import the movie and embed it fine but it just loops
    forever and I can't seem to get it to redirect.
    Can anyone help with this one?
    Thanks,
    James :-)

    Hi,
    I tried that but it still doesn't work.
    When I look at the HTM is contains the following:
    AC_FL_RunContent(
    'codebase', '
    http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
    'width', '720',
    'height', '480',
    'src', 'movietest',
    'quality', 'high',
    'pluginspage', '
    http://www.macromedia.com/go/getflashplayer',
    'align', 'middle',
    'play', 'true',
    'loop', 'false',
    'scale', 'showall',
    'wmode', 'window',
    'devicefont', 'false',
    'id', 'movietest',
    'bgcolor', '#ffffff',
    'name', 'movietest',
    'menu', 'true',
    'allowFullScreen', 'false',
    'allowScriptAccess','sameDomain',
    'movie', 'movietest',
    'salign', ''
    ); //end AC code
    Coudl this be what is causing the issue:
    'allowScriptAccess','sameDomain',
    James :-)

  • Question about import database pk, fk

    Hi
    I want to ask a question about imported database. I imported database and I noticed tables doesnt have Primary key or foreign key. They havent relation between eachs. Why can this occured ?
    is it about import or another something?

    yeah ı am surprised none of tables have pk or fk ..
    but ı want to show you http://i51.tinypic.com/2hedc9d.jpg
    what is blue shapes in there ?
    can be foerign keys ?

  • Question about delete statement

    I have question about delete statement...
    i am performing some simple delete statement against one table..but its taking so long..How can we check whether particular delete statements actually deleting records or not..?

    Is the associated select-statement returning rows or not?
    If yes -> delete is deleting
    If no -> delete is just using CPU-cycles
    To tune the delete-statement, you have to tune the corresponding select-statement. To tune the select-statement, you want to read the thread When your query takes too long ...

  • Basic question about importing wma files

    Hi, I have a basic question about importing wma files. I ripped some cd's on a Mindows computer using Media Player, but now want to copy them to my Mac and use them in iTunes on my Mac. when I use Import in iTunes, nothing happens and I cant even seem to copy them one by one using the Music folder.
    Can someone help me?
    thanks
    eMac   Mac OS X (10.4.4)  

    iTunes for Mac doesn't support .wma files.
    If you can use a PC to convert them, you can use one of many freeware applications. Google for 'wma to mp3'.
    For the Mac there's the shareware program EasyWMA that can convert them.
    Hope this helps.
    M
    17' iMac fp 800 MHz 768 MB RAM   Mac OS X (10.3.9)   Several ext. HD (backup and data)

  • Some questions about importing HTML files

    Hi, folks
    Let's suppose we want to import a pack of HTML files formatted in HTML5 wit's it's CSS into a double-oriented folio. A couple or three questions about that, please:
    1. Is there a limit for a reasonable quantity of HTML files I can import into a folio? I mean.. 100 would be way too much, for instance?
    2. These HTML files could be navigated and referenced from inside TOC-pages made in InDesign,right? (navto://..., I gues?)
    2. Will it be possible, by means of HTML adaptative design techniques, to treat both orientations (vertical and horizontal) as different viewports or screen sizes so that the design adapts for instance the column width with its CSS?
    3. That said, will the InDesign final app. respect that adaptative CSS rules?
    I am asking this because we are looking for a way to inject big quantities of content with a very similar design into our application in a really fast and automatizable way and I have the suspicion* that importing HTML5 preformated CSS files could be the a very good and simple alternative to importing XML into InDesign templates as we start out content as tagged almost-html files.
    Thanks a lot
    Gustavo Sánchez (Posting from Madrid)

    I assume you are asking about using HTML articles.
    1. There is no limit beyond simply keeping things reasonable.
    2. Yes. Just use navto://articlename
    3. Yes. I've used min-width of 768 and max width of 1024 to control it.
    4. InDesign does not enter into any of this with the exception of using the folio builder panel. Everything else is done in Dreamweaver or whatever program you decide to use for the article.
    If you want to restrict the HTML articles to one orientation or the other, use the _h and _v suffixes.
    Bob

  • Newbie Question about FM 8 and Acrobat Pro 9

    Hello:
    I have some dcouments that I've written in FM v8.0p277. I print them to PDF so that I can have a copy to include on a CD and I also print some hard copies.
    My newbie question is whether there is a way to create a  PDF for hard copy where I mainitain the colors in photos and figures but that the text that is hyperlinked doesn't appear as blue. I want to keep the links live within the soft copy. Is there something I can change within Frame or with Acrobat?
    TIA,
    Kimberly

    Kimberly,
    How comes the text is blue in the first place? I guess the cross-reference formats use some character format which makes them blue? There are many options:
    Temporarily change the color definition for the color used in the cross-reference format to black.
    Temporarily change the character format to not use that color.
    Temporarily change the cross-reference definition to not used that character format.
    Whichever method you choose, I would create a separate document with the changed format setting and import those format into your book, create the PDF and then import the same format from the official template.
    - Michael

  • Concept about  import statements

    Hi all,
    I write a GUI application and I notice I have to write these two import statement at the same time in order to handle the events:
    import java.awt.*;
    import java.awt.event.*;
    Why is that? Does java.awt.* not include java.awt.event.*?
    thank you,
    Li

    I'm unsure what you are talking about...do you mean something like this?
    import java.util.LinkedList;
    import java.util.concurrent.*;-or- perhaps something like:
    import java.util.*;
    import java.util.LinkedList;In the case of the former, that is perfectly legal and possible. In the case of the latter, it is possible, but absurd. Perhaps neither of these were what you were talking about. If not, let me know more precisely what you mean and we'll see about it.

  • Some questions on import statements.

    When I see
    import java.awt.*
    import java.awt.event.*
    am I on track interpreting this to mean that you want to be able to use any of the classes found in package java.awt?
    why would import java.awt.event.* be necessary if event is a class in the java.awt.* package you're importing in the second import statement up above?
    does * mean like a "wildcard" which allows you to utilize
    anything that is part of java.awt?

    It allows you to use any of the classes in that directory, but not any classes in sub-directories of that directory.

  • Question about 'write' statement

    Hi,
    A question on write statement.
    I have a internal table itab which has field var. I am looping at this itab and writing horizontal heading output like below.
    example on the output heading:
    (3 spaces) itab-var (20 spaces) itab-var (20 spaces) itab-var.
    the coding is:
    loop at itab.
    write: 3 itab-var.
    endloop.
    I want to increase the space by 20 for every loop. How to increase this 3 by 20? Can we accomplish this way?
    Thank you for your time.

    hi krishen,
    just add 20 inside the loop , so that after every loop its value increases by 20
    for example:
    data: v  type i.
    v=3.
    do 3 times.
    write: at v(20).
    v=v+20.
    end do.
    hope it will help you
    regards
    Rahul sharma
    Edited by: RAHUL SHARMA on Sep 4, 2008 7:47 AM

Maybe you are looking for

  • Can't bind server to OD, replication broken, users at some sites can't auth

    Hi all, Having a doozy of a problem with our OD at the moment, hopefully someone can help The setup: 1 OD master and 3 replicas at head office here, all running 10.5.5 (issue also occurred in 10.5.4) Around a dozen remote AFP & SMB file servers, all

  • How to find out email id from CUA ?

    Hi, I would like to have a list of user id with email from CUA. Is there any table/report from where I can get both ? All users are maintained with user id and email into SU01. Thanks...

  • Report links from one dashboard(report) to another dashboard with prompt

    There are two dashboards 'Chart' and 'Transaction details' . I am trying to link from one report(dashboard called 'Chart') to another dashboard(Transaction details). In first dashboard (screenshot 1) there is a column called 'Day' which is like date.

  • Firmware File Corrupt

    Hello, Each time after dowloading, updating, backing up all of the sudden the same error came up for both my iPhone and hubby's iPod Touch: Firmware File Corrupt Unconnect, reconnect, and try again later Anyone know if this is due to way too much tra

  • JMSBC application is not deploying

    Hi all, i am creating an bpel in which i am using an soap BC to pass input and get response, after that invoking an HL7BC after that i am using an JDBC BC to get result, then i am invoking an JMSBC which collects result from jdbc and then write it to