Problem with creating a new object

It's my stupid simple code:
class Readers {
     int i, a;
public     Readers(int i, int a){
public static void main(String[] args) {
Readers[] d = new Readers[5];
d[4] = new Readers(2,2);
System.out.println(+d[4].i);
Why do I get the answer 0, instead of 2?

See the comments in your code:
class Readers {
    int i, a; // the global variables 'i' and 'a' are both initialized with zero
    public Readers(int i, int a){
        // the local values 'i' and 'a' are lost: you don't do anything with them!
    public static void main(String[] args) {
        Readers[] d = new Readers[5];
        d[4] = new Readers(2,2);
        System.out.println(d[4].i);
} // note that you don't need semi-colons after a '}'

Similar Messages

  • BADI:problem with creating a new tab in BADI

    Hi
    I'm new to BADI's.
    i have a requriement to add a new tab in the MIGO transaction and add a field in that new tab .
    my Functional specification author is suggesting to use the BADI "MB_MIGO_ITEM_BADI" to create a new TAB .
    But i'm not find any function code availale in this BADI .
    Can anybody tell me how to use this BADI "MB_MIGO_ITEM_BADI" to create a new TAB .
    Also can anybody provide me any documentation available in designing a new TAB or new screen using BADI's ?

    Hi pawan
    Try this badi :   MB_MIGO_BADI  -
    (BAdI in MIGO for External Detail Subscreens)  as the name suggest ,
    If you want to add a screen in header level use : Method : PBO_header an code as :
        e_cprog   = 'ZMMPRM0001'.     """ Your screen created
        e_dynnr   = '1000'.                     "Your screen No
        e_heading = 'TEXT ID '(004).    """" Name of the screen to be created .
      ELSE .
        e_cprog   = 'ZMMPRM0001'.
        e_dynnr   = '1000'.                     "External fields: Display
        e_heading = 'TEXT ID '."(004).
    or if at item level
    u can use methid : PBO_DETAIL
    for item level screen creation . and code in the same maaner ..
    You can explore the remaning methods as per your requirements .
    Hope it helps ..!
    Regrads
    Swapnil P KAmble

  • Problem with creating a new contact....gmail?

    Hi,
    When I create a new contact on my Iphone (5S) it doesn't appear as normal.  It only works when I say show all contacts which includes my gmail account.  Then I see all these random people who I e-mailed years ago....I don't want this...
    How do I just save a phone number/ new contact?
    Thanks,
    Gary

    Hi Gary,
    It sounds like when you are adding contacts that it is going to a different syncing service. Take a look in Settings > Mail, Contacts, Calendars and scroll down to the Contacts section to change the Default Account to what you want to use. 
    Contacts settings
    http://help.apple.com/iphone/8/#/iph96b20610
    Take it easy,
    -Norm G. 

  • Problems With Creating Group of Objects from a Collection

    Hi, please kindly help.
    I have a Collection. Its name is "activities". It is a collection of the Activity object with "color" as one of the attributes. I am writing a method and takes "activities" as a parameter (see below). The method is supposed to group "activities" by "color" and return a Collection called "activitiesGroups". And I have created an "activitiesGroup" (note: singular not plural) class with the getters and setters of all its attributes.
    I first sorted the "activities" by color. So far so good. Thereafter, I am iterating through this sorted list. If activity.getColor().trim() is tested different, I know that a new group, i.e., activitiesGroup, should be created and I should code activitiesGroups.add( activitiesGroup );Problems are:
    1. If I am at the first record of the sorted collection while iterating, I do not what to add a new group to the returned List activitiesGroups. I want to greate a new group only.
    Because "colorString" is initialized as a blank, when I code activitiesGroups.add( activitiesGroup );, I depend on that I am not at the first record of the sorted collection by testing if colorString.length(); is not a zero. I do not think it is the correct way to do it.
    What is the proper way of knowing I am at the first record of the sorted collection while iterating?
    2. I have to sum up two of the attributes of the ActivitiesGroup object: increaseToValue and decreaseToValue. While iterating, I repeat for each record within a group:
    aGroup.setIncreaseToValue( increase );
    aGroup.setDecreaseToValue( decrease ); How do I avoid the repetition?
         private Comparator colorComparator;
         private List activitiesGroups;
         private ActivitiesGroup aGroup;
         private String colorString = "";
         private String nextColorString = "";
         private BigDecimal increase;
         private BigDecimal decrease;               
         public List groupingByColor( List activities ) {
              if ( activities == null) {
                   return new ArrayList(0);
              if ( !activities.isEmpty() ) {
                   Collections.sort( activities, colorComparator);  // It works.
                   activitiesGroups = new ArrayList();
                   Iterator it = activities.iterator();
                   while ( it.hasNext() ) {
                        Activity activity = ( Activity )it.next();
                        nextColorString = activity.getColor().trim();                    
                        if ( !nextColorString.equalsIgnoreCase( colorString.trim() ) ) {
                             int length = colorString.length();
                             if ( length != 0 ) { activitiesGroups.add( aGroup ); } // Problem # 1
                             aGroup = new ActivitiesGroup();
                                                              aGroup.setColor( activity.getColor() );
                             increase = increase.add( activity.getIncreaseToValue() );
                             decrease = decrease.add( activity.getDecreaseToValue() );
                             aGroup.setIncreaseToValue( increase ); // Problem #2: repeated for every record in a group
                             aGroup.setDecreaseToValue( decrease ); // Problem #2: repeated for every record in a group
                        } else {
                            increase = increase.add( activity.getIncreaseToValue() );
                            decrease = decrease.add( activity.getDecreaseToValue() );
                            aGroup.setIncreaseToValue( increase ); // Problem #2: repeated for every record in a group
                            aGroup.setDecreaseToValue( decrease );      // Problem #2: repeated for every record in a group                         
                                                                    colorString = nextColorString;
              return activitiesGroups;
         }

    I first sorted the "activities" by color. So far so good. Thereafter, I am iterating through this sorted list. If activity.getColor().trim() is So in fact you are not dealing with an arbitrary Collection (as you stated in the first place), you are dealing with a List.
    You should know that there is a way to do this just with an iterator on an arbitrary collection - without needing to sort your list, and do it in O(n) time.

  • Problem with creating a new webapp

    Hi All,
    i wrote a web app using tomcat as a web server, servlet and jsp container.
    and i would like to deploy my app to weblogic5.1.
    i created a directory D:\weblogic\MyAppName and placed my app file in it.
    i have created an entry for my web app in weblogic.properties:
    weblogic.httpd.webApp.WebBcc=MyAppName
    this works fine.
    the problem is that my context path is more complicated : WebBcc/EN
    and it is hard coded in all my jsp files.
    so i tried this:
    weblogic.httpd.webApp.WebBcc/EN=MyAppName
    this end up in file not found!!
    is there a way to specify a context name that contains "/" ???
    thanks in advance
    Yaron.

    I don't see any information within the specification or documentation which
    mentions conventions pertaining to the context name. I tried with an
    exploded and war format, and the inclusion of "/" in the context name always
    results in a 404 error. I don't think its possible and is probably related
    to request path elements.
    Patrick
    "Jacobson Yaron" <[email protected]> wrote in message
    news:[email protected]..
    Hi All,
    i wrote a web app using tomcat as a web server, servlet and jsp container.
    and i would like to deploy my app to weblogic5.1.
    i created a directory D:\weblogic\MyAppName and placed my app file in it.
    i have created an entry for my web app in weblogic.properties:
    weblogic.httpd.webApp.WebBcc=MyAppName
    this works fine.
    the problem is that my context path is more complicated : WebBcc/EN
    and it is hard coded in all my jsp files.
    so i tried this:
    weblogic.httpd.webApp.WebBcc/EN=MyAppName
    this end up in file not found!!
    is there a way to specify a context name that contains "/" ???
    thanks in advance
    Yaron.

  • Problem with creating a new file in the Filter

    hi,
    i have the following problem.
    1) For all requests ending with *.xml (for example requests such as http://www.asdf.com/feeds/myfile.xml ) i have mapped it to a filter
    2 ) In the filter i did the following...................
    //getting the file name from the url
    //create the file if it does not exists..................
    chain(request,reponse);
    //done
    problem is
    3) a) For files which iam not creating in filter (i.e files which are already there) the response is proper it is returning a xml file
    b) But for files which are not there already , which we are creating in the filter dynamically it is showing a 404 (i.e file not found message)
    But if i refresh again in the browser it is getting a valid XML file.......................................
    I could not able to figure it out why it is returning 404 error in cases where the file is being created dynamically.................................
    Can any one guide me resolving this problem?

    Hi pawan
    Try this badi :   MB_MIGO_BADI  -
    (BAdI in MIGO for External Detail Subscreens)  as the name suggest ,
    If you want to add a screen in header level use : Method : PBO_header an code as :
        e_cprog   = 'ZMMPRM0001'.     """ Your screen created
        e_dynnr   = '1000'.                     "Your screen No
        e_heading = 'TEXT ID '(004).    """" Name of the screen to be created .
      ELSE .
        e_cprog   = 'ZMMPRM0001'.
        e_dynnr   = '1000'.                     "External fields: Display
        e_heading = 'TEXT ID '."(004).
    or if at item level
    u can use methid : PBO_DETAIL
    for item level screen creation . and code in the same maaner ..
    You can explore the remaning methods as per your requirements .
    Hope it helps ..!
    Regrads
    Swapnil P KAmble

  • Problem with creating a new Siebel account using Web Service and ADF

    Problem solved.
    Edited by: noah.fang on Mar 15, 2011 3:45 PM

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by phil housley ([email protected]):
    <HR></BLOCKQUOTE>
    sorry this is first time I tried to reply on this group
    The USER is SYSTEM and there is no real password when first installed. However you do need to type something in the password field . This can be anything if you have not added a password.
    Phil
    null

  • VBA: problems in creating and storing objects in array with loop

    I created a Class named Issue. Then I created a function that creates Issue objects, set their properties with data from a worksheet and store them into a variant array through a loop. the problem is that everytime that the loops runs it overwrites the properties
    of the same object instead of creating a new object, setting its properties. Would anyone know how to solve that? The loop code goes below:
     'Stores all the Issues objects in an Array
    Function StoreAllIssues() As Variant
    Dim IssuesSheet As Worksheet
    Set IssuesSheet = Sheet1
    Dim intLastRow As Integer
    intLastRow = Uteis_Jorge.LastRowFunc(IssuesSheet, 1)
    Dim IssuesArray() As New Issue: ReDim IssuesArray(0)
    For i = 2 To intLastRow
        Dim MyIssue As New Issue
        MyIssue.IssueName = IssuesSheet.Cells(i, 1)
        MyIssue.Suggestion = IssuesSheet.Cells(i, 2)
        MyIssue.Priority = IssuesSheet.Cells(i, 3)
        MyIssue.Resolution = IssuesSheet.Cells(i, 4)
        MyIssue.JobStatus = IssuesSheet.Cells(i, 5)
        MyIssue.AssignedTo = IssuesSheet.Cells(i, 6)
        Set IssuesArray(i - 2) = MyIssue
        ReDim Preserve IssuesArray(i - 1)
    Next i
    ReDim Preserve IssuesArray(i - 3)
    StoreAllIssues = IssuesArray
    End Function
    Jorge Barbi Martins ([email protected])

    Hi Jorge,
    You can set the MyIssue to Nothing every time you don't use the MyIssue object, in this way, the array will properly store the new MyIssue object:
    For i = 2 To intLastRow
    Dim MyIssue As New Issue
    MyIssue.IssueName=IssuesSheet.Cells(i,1)
    Set IssuesArray(i - 2) = MyIssue
    ReDim Preserve IssuesArray(i - 1)
    Set MyIssue = Nothing
    Next i
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Hi all, i'm new and facing a problem while creating a new file for Xcode. I can't select the box "with XIB for user interface" if the subclass is "UIViewController".this problem happen after i upgrade Xcode to 4.6 version.Appreciate for any help rendered.

    Hi all, i'm new to Mac book & Xcode. I'm learning and facing problems while creating a new file for Xcode. Before i upgrade the software, i have no issue to create simple steps in apps. After upgrade Xcode to 4.6 version, i'm facing lot's of issue eg.
    1) "the identity "iphone developer" doesn't match any valid certificate/ private key pair",
    2) can't select the box "with XIB for user interface" if the subclass is "UIViewController"..
    Appreciate for any help rendered.

    Mikko777 wrote:So what is the best?
    I wouldn't judge. I've been to Arch for a week, you know? But as said, it's VERY close to it.
    What I dislike after a week is makepkg not handling dependencies automatically (which would be overhead, so probably not appropriate).
    Mikko777 wrote:Also theres KDEmod for modular kde, dunno if its for 64 bits tho.
    Don't actually need that as said ... I see no real benefit of having that other than not beeing a KDE user or having Gentoos useflags.
    Mikko777 wrote:PS:You produce a lot of text and welcome smile
    Yeah. Wonder why I'm still employed? So do I ...

  • Problem with create universe on Business Objects XI 3.1 base on SAP Query

    Hello,
    I have a problem with create universe on Business Objects XI 3.1 base on SAP Query.
    The problem is hierarchy. Massage on Busines Objects is :
       OWBS_ELEMT__ISTKOSZT(cube ICPC01/BEX_ICOC01):Exception condition  "HIERARCHY NOT FOUND" raised.(WIS 10901) 
    Query in BEX run OK.
    Best regards.
    Ela.

    Hello,
    Thanks for response.
    When I run BEX QUERY, all works OK.
    All hierarchies was created and activated  on system BW.
    This situation appears after upgrade BW to SAP NetWeaver 7.3.
    Before upgrade I created universe without any problems.
    Regards Ela

  • Problem with creating new user in portal = portlet is not visible

    Hi,
    I've got a problem with creating new users in portal. In the Administer tab of the builder is the user portlet not visible.
    How can I make this portlet visible?
    Please Help
    thank you...
    Gilbert

    Hi..my problem slightly similar.
    I created one new user, and didn't select anything from "Public Groups Assignment" and "Privilege Assignment" for him.
    I expect the user will be a public user.
    But, when he try to logged in the portal,
    He cannot see all the PORTLETS related to database values..
    All he can see just LINKS -that all in my portal right now beside the report from database that the user cannot see :)
    So, what did i do wrong?
    Plz Advise, and thanks.

  • I have problems with creating new projects in iMovie.

    I have problems with creating new projects. When i try, the mac says the following "Make sure there is enough disk space and that you have permission to write the projects to the drive." I have 8GB available, so its not that.

    thanks for your support
    lol

  • A different way to create a new object?

    Hi all!
    I have an array of type Object were I'm inserting different data types (String,Integer and so on..) now I want to go over this array and I want to create
    a new object that is not(!) a clone of the object in a given position but is the same type (the downcasted type)
    I want to implement it in a single command but not in series of if (.. instance of ..)
    The new value should be inserted into an array of Object too so I assume it will implicitly downcast it automatically.
    how can I do that? I hope you understand the problem..
    thanks
    omer
    Edited by: omerkap on Dec 29, 2009 8:27 AM

    omerkap wrote:
    what do you want?!To engage in a reasonable discussion. How about you?
    I came here to ask a very specific question about a way to implement something.Many folks do. And they often ask how to implement their solution in a way that is impractical or inefficient. Sometimes, they attempt to incorporate better ideas when given suggestions for better implementations. Sometimes, they just throw miniature temper tantrums.
    You purposed another way? ok, thanks, but I need to know how to do it in the original way I asked.Well, no. You said what you wanted to do. Now that it's a need, my advice is different.
    I proposed an idea for a simple solution to accomplish the general requirements you originally mentioned. If you have design restrictions that mandate you write code in a certain way or to fulfill a particular design, then you should comply with those restrictions. Personally, I like to guide folks toward a useful design. If you don't want to be guided that way, that's certainly your prerogative.
    As it stands now, it sounds like you have an assignment. And I suspect that assignment isn't intended to test your ability to copy a solution someone gave you on an internet forum. It sounds like the assignment requires the use of a lengthy if chain. I recommend you comply with your requirements.
    As an aside, you could use a Map<String, InstructionBuilder>(), but you'd be getting into some serious class bloat for what I presume is a relatively small, simple app. You could also probably hack up something with reflection, but that's probably out-of-bounds with your requirements as well.
    You don't want to answer? Don't know where you got that idea. I post here only when I want to.
    ~

  • It will not parse! Creating a new object in the universe

    Hi, we have a universe and BO reports. They work fine for our clients. We are on BO XI r3.1. Now, one client captures an additional piece of info. They would like to report against this and add it high up on our drilling heirarchy. "Sure, no problem". For the following I was logged in as administrator.
    The additional data field is a 3 character code.
    1) We added an additional column to the actual database table.
    2) In Universe Designer, I refreshed universe structure and could see the additional column
    3) Created an object 'Acode' that refers to db.new_field
    4) Exported universe
    Maybe worth mentioning that I can see this object and use it in reports fine in Infoview.
    Now, I need to create a new object that will be one of 2 strings based on the 3 character code (Acode) i.e. the 'Atype' can be X or Y.
    Here's my code and it just will not parse:
    CASE
    WHEN @Select(AFolder\Acode) = 'CEL'
    THEN 'X'
    ELSE u2018Yu2019
    END
    Error I get is:
    Parse failed:Eception:DBD ODBC SQL Server driverStatement could not be prepared.State 42000
    I'd appreciate any help, believe me I have searched the forums!
    Thanks, Eddie

    Look at following SAP NOtes.
    1373739
    1184304
    Regards,
    Bashir Awan

  • Problems with repainting in new JD 9.0.4.0

    I just installed new JD 9.0.4.0 . I think that from this moment I have problems with painting java graphics objects (for example Application Module tests or simple login dialogs). When I move that window, its remains are left on the screen until I overlap them with other non-java window. Has anybody the same experience ?

    I haven't seen this. One thought (call it grasping at straws) would be to set the environment variable: J2D_D3D=false
    That disables Java2D and sometimes fixes some quirks.
    Rob
    Team JDev

Maybe you are looking for

  • Help!How to use JCheckBox in a Rolloverenabled JToolBar

    I have added a JCheckBox and a JButton(they all have a icon) in JToolBar , and set the toolbar rolloverenabled through the api "setRollover(true)",yes I got the right result that when my mouse point enters the JCheckBox or the JButton,they will show

  • White screen when pressing home button and getting text

    Strange thing, hopefully software bug. I press the home button to check time and all that shows is a white screen. It's not the white screen of death because I can simply press the sleep button and then go straight back to what I was doing, pressing

  • My ipod touch battery shows up empty after being charged

    Hi, I have had my Ipod touch generation four for a few months and I have noticed in the past week that the battery doesnt show up charged after being fully charged it just displays empty. When I go into an app or a game the battery shows up green and

  • Fios is in my building - so why doesn't Verizon know that?

    Last month Verizon installed Fios in my 8 unit condo and currently has one of the unit owners outfitted with and paying for service.  Upon install, the engineer told my fellow condo association trustee (the one with the service) that the building was

  • AVCHD - 2560 x 1080

    I've just been messing around with some AVCHD...tut. Using Log and Transfer, the files are coming in as 2560 x 1080 pixels and there's no way to get it to behave in the timeline. It seems to be in some mega cinemascope frame size. No matter what you