Need algrithim for constantly making new objects

How would I go about making an object and then remake the same object again but with a different name.
here is the problem:
for(int i=0;i<23;i++){
//But i want the second time to run around and create a Printer object
//named something else not printer.
Printer printer = new Printer();
any help would be appreciated

Well I my case I'm trying to get different names. So I guess the easist thing I can do is to make an array. But then it brings me to this question,
This is my class:
import java.awt.*;
public class Printer {
     public void init(){
     public void paint(Graphics g,String string,int x,int y){
          g.drawString(string,x,y);
}if I wanted to make an array out of it like so:
Printer[] print = new Printer[xAmount];It says nullPointerException when I try to access the class's function by doing this:
print[0].paint(g,"test",2,3);What can I put in print[0] to make it not null? I mean you can put numbers and letters. (
Message was edited by:
jkhoa
Message was edited by:
jkhoa

Similar Messages

  • Need help for using at new command

    Hi
      experts can u please help me .i want to execute the following :
    customer name       item no
      gaurav                      1
    gopi                          2
    santosh                      1
    raju                            2
    gaurav                         1
    gopi                            2
    i want that if there is change in customer no it's corresponding item no will be trigered
    but for same customer no
    eg:
    gaurav     1    {in one row
    gaurav     1    {  it should execute
    gopi     2   {in one row
    goip     2   {it should execute

    Check with below program and it is simlar to your requirement
    *& Report  ZTEST_IEVENTS
    REPORT  ZTEST_IEVENTS no standard page heading
                          line-count 40(2).
    tables : vbap.
    data : begin of i_vbap occurs 0,
           vbeln like vbap-vbeln,
           posnr like vbap-posnr,
           matnr like vbap-matnr,
           kwmeng like vbap-kwmeng,
           netpr like vbap-netpr,
           end of i_vbap.
    data wa_vbap like line of  i_vbap.
    data v_flag type c.
    select-options s_vbeln for vbap-vbeln obligatory.
    start-of-selection.
    select vbeln
           posnr
           matnr
           kwmeng
           netpr from vbap
           into table i_vbap
           where vbeln in s_vbeln.
    sort i_vbap by vbeln posnr.
    end-of-selection.
    loop at i_vbap.
    move i_vbap to wa_vbap.
    at first.
    write:/2 'Order #',15 'Item #',28 'Material #',50 'Qty', 70 'Net value'.
    skip 1.
    endat.
    at new vbeln.
    write:/2 wa_vbap-vbeln,15 wa_vbap-posnr,28 wa_vbap-matnr,
            47 wa_vbap-kwmeng,65 wa_vbap-netpr.
    v_flag = 'X'.
    endat.
    if v_flag ne 'X'.
    write:/15 wa_vbap-posnr,28 wa_vbap-matnr,
            47 wa_vbap-kwmeng,65 wa_vbap-netpr.
    endif.
    at end of vbeln.
    sum.
    skip 1.
    write:/5 'Sub totals', 47 i_vbap-kwmeng,65 i_vbap-netpr.
    skip 1.
    endat.
    at last .
    skip 1.
    sum.
    write:/5 'Grand Totals',47 i_vbap-kwmeng,65 i_vbap-netpr.
    skip 1.
    write:/ 'end of page', 'Footer'.
    endat.
    clear v_flag.
    endloop.
    Thanks
    Seshu

  • Work Center Changes need data for previous and new work center

    Hi All,
    I have a requirement as the organisation is going through RESTRUCTURING. In ECC in Plant Maintainance they are changing Work Center. E.G.
    Work Center OLD : ABC
    Work Center NEW : XYZ
    Now the requirement is I have data for ABC already coming in BI Prod. Env. Now when they will change ABC to XYZ the new data will come for XYZ.
    Reporting Reqmt:
    Data In Cube
    Work Center     No. of Maintainence Orders
    ABC                             10
    XYZ                             20
    When user run the report it should and gives input in Work Center variable as " XYZ" then
    XYZ -- 30
    Presently it is showing
    ABC --10
    XYZ --20
    They have list of OLD Work Center mapping to NEW Work Center.
    Now, Can anyone tell me is it possible to achive this scenario.
    Thanks,
    Mayank

    Hi,
    find the below link it has similar issue ,
    Re: mapping between old/new material codes in BW
    Regards,
    Satya

  • How to create a new object for a particular class?

    Hi,
      Can anybody please tell  the steps for creating a new object for a particular class.
    Thanks,
    Sreeja

    Declare the object as TYPE REF TO the class and use the CREATE OBJECT statement to create an object.
    DATA <obj_name> TYPE REF TO <class_name>.
    CREATE OBJECT <obj_name>.
    Please mark points if the solution was useful.
    Regards,
    Manoj

  • Script for making an object the artboard size.

    I am looking for some help on trying to make an object the exact size of the artboard.  This is something I do on a daily basis for several different reasons and it would be very helpful if this can happen automatically for whatever size the artboard may be.  As I understand it the only way is with a script but I have no experience with making illustrator scripts, im definately no programmer.  I have set up quickkeys in the past to copy from the artboard inputs when you are on the artboard tool but these round to the nearest .01 and this is not accurate enough for what I am working with.  Also if I do this with multiple pages open illustrator is very slow to respond to the artboard tool.  If anyone has any idea where to start or has seen other such scripts I would greatly appreciate it.  Thank you.
    Below is a script that I saw on here that I believe may contain what I need but now knowing programming I have no idea where to start on editing.  All I need is the part where an object is placed on the artboard that is the exact same size as the artboard.  If anyone can advise on editing I would greatly apprecaite it.
    #target illustrator
    function main() {
         if (app.documents.length == 0) {
              alert('Open a document before running this script');
              return; // Stop script here no doc open…
         } else {
              var docRef = app.activeDocument;
              with (docRef) {
                   if (selection.length == 0) {
                        alert('No items are selected…');
                        return; // Stop script here with no selection…
                   if (selection.length > 1) {
                        alert('Too many items are selected…');
                        return; // Stop script here with selection Array…
                   } else {                   
                        var selVB = selection[0].visibleBounds;
                        var rectTop = selVB[1] + 36;
                        var rectLeft = selVB[0] - 36;
                        var rectWidth = (selVB[2] - selVB[0]) + 72;
                        var rectHeight = (selVB[1] - selVB[3]) + 72;              
                        selection[0].parent.name = 'CC';
                        selection[0].filled = false;
                        selection[0].stroked = true;
                        var ccColor = cmykColor(0, 100, 0, 0);              
                        var ccCol = spots.add()
                        ccCol.name = 'CC';
                        ccCol.color = ccColor;
                        ccCol.tint = 100;
                        ccCol.colorType = ColorModel.SPOT;
                        var cc = new SpotColor();
                        cc.spot = ccCol;                   
                        selection[0].strokeColor = cc;
                        selection[0].strokeWidth = 1;                   
                        var tcLayer = layers.add();
                        tcLayer.name = 'TC';
                        var padBox = pathItems.rectangle(rectTop, rectLeft, rectWidth, rectHeight, false);
                        padBox.stroked = false;
                        padBox.filled = true;
                        var tcColor = cmykColor(0, 100, 90, 0);         
                        var tcCol = spots.add()
                        tcCol.name = 'TC';
                        tcCol.color = tcColor;
                        tcCol.tint = 100;
                        tcCol.colorType = ColorModel.SPOT;
                        var tc = new SpotColor();
                        tc.spot = tcCol;
                        padBox.fillColor = tc;    
                        padBox.move(docRef, ElementPlacement.PLACEATEND);
                        artboards[0].artboardRect = (padBox.visibleBounds);
                        redraw();
                        rectWidth = (rectWidth-72)/72;
                        rectWidth = roundToDP(rectWidth,1);
                        rectHeight = (rectHeight-72)/72;
                        rectHeight = roundToDP(rectHeight,1);
                        var textString = rectWidth + ' x ' + rectHeight;
                        prompt('Copy Me', textString);
    main();
    function roundToDP(nbr, dP) {
         dpNbr = Math.round(nbr*Math.pow(10,dP))/Math.pow(10,dP);
         return dpNbr;
    function cmykColor(c, m, y, k) {
         var newCMYK = new CMYKColor();
         newCMYK.cyan = c;
         newCMYK.magenta = m;
         newCMYK.yellow = y;
         newCMYK.black = k;
         return newCMYK;

    Thanks to CarlosCanto for the original script, it was very a very helpful starting point to optimize one of our workflows. We customized it a bit to maintain the aspect ratio (just takes the greater of the width / height and scales proportionally to the artboard size), and also center up the object in the middle of the artboard once scaling is complete. I hope it is helpful to someone:
    #target Illustrator
    //  script.name = fitObjectToArtboardBounds.jsx;
    //  script.description = resizes selected object to fit exactly to Active Artboard Bounds;
    //  script.required = select ONE object before running; CS4 & CS5 Only.
    //  script.parent = carlos canto // 01/25/12;
    //  script.elegant = false;
    var idoc = app.activeDocument;
    selec = idoc.selection;
    if (selec.length==1)
            // get document bounds
            var docw = idoc.width;
            var doch = idoc.height;
            var activeAB = idoc.artboards[idoc.artboards.getActiveArtboardIndex()]; // get active AB
            docLeft = activeAB.artboardRect[0];
            docTop = activeAB.artboardRect[1];
            // get selection bounds
            var sel = idoc.selection[0];
            var selVB = sel.visibleBounds;
            var selVw = selVB[2]-selVB[0];
            var selVh = selVB[1]-selVB[3];
            var selGB = sel.geometricBounds;
            var selGw = selGB[2]-selGB[0];
            var selGh = selGB[1]-selGB[3];
            // get the difference between Visible & Geometric Bounds
            var deltaX = selVw-selGw;
            var deltaY = selVh-selGh;
            if (sel.width > sel.height) {
                var newWidth = docw-deltaX;
                var ratio = sel.width / newWidth;
                sel.width = newWidth; // width is Geometric width, so we need to make it smaller...to accomodate the visible portion.
                sel.height = sel.height * ratio;
            } else {
                var newHeight = doch-deltaY;
                var ratio = sel.height / newHeight;
                sel.height = newHeight;
                sel.width = sel.width / ratio;
            sel.top = (doch / 2) - (sel.height / 2);
            sel.left = (docw / 2) - (sel.width / 2);
        else
                alert("select ONE object before running");

  • Creation of new object link for DMS

    i have searched a lot  about Creation of new object link for DMS on internet .
    and all replies  focus on that documentation :
    1.     Program two screens for the following module pools for the SAP object that is to be linked additionally:
    u2013 SAPLCV00
    u2013 SAPLCVIN
    The process logic must be according to that of screen 0204 in program SAPLCV00 and must not be changed.
    2.     Create the function module OBJECT_CHECK_XXXX (XXXX = name of the SAP object).
    i need  to know how to implement that  in more detailed step by step
    as  i know DMS and  abap also.

    Hi Reda,
    Hope the below URL will help to understand how the Process of adding a object link works.
    Enhancement Without Modification of the Object Links - Engineering Change Management (LO-ECH) - SAP Library
    Thanks & Regards,
    Seshadri.

  • Need Ideas for creating and using Custom Business Object

    Hello Guys,
    I am developing an application which uses a Request->Approve->Create approach for creating Purchase documents.
    Now I am a little puzzled about how to make use of the Business Object BUS2014.
    The application I am developing has its own unique 'Request Number'  (say REQID)  which will point to the Request for Creation of a purchase order.
    Whenever a Request is created (from a Z-Tcode) a workflow needs to be initiated and it has to be sent to the approver.
    The Purchase Document will be created once the approver approves.
    Now my confusion here is, if I use BUS2014, the object will be instantiated only during the final step of the workflow. But I need an instance during the beginning of the Requestor ->Approver negotiations as I am playing with events. These events needs an Object_key.
    How should I proceed here?
    Should I create a new logical Business Object like ZPOREQ where I have the above mentioned REQID as the key?
    And should I have an attribute of type BUS2014 inside the custom BO?
    How will I make use of the methods like BUS2014.Create etc which I may need to create the purchase document?
    Any small direction will be a huge help for me to get used to this wilderness.

    Hi,
    You should continue with the ABAP class idea. The business objects are kind of "obsolete" already, and if there is a need to create a new "object", ABAP classes are the way to go. Business objects are still useful, but I normally use them only when an existing standard business object fulfills the requirements (possibly with slight additions) which is almost never. 
    From my point of view you can use the existing class. Depending on the circumstances I normally have just one class that I use for both workflow and the possible other functionality that is required, but you have to understand that I have this goal in my mind already when starting the development process. As your class most probably has many useful features already (such as you have the header and item data as attributes etc. (if I understood correctly?), these are also useful in in workflow (class attributes will be available in WF container etc.). 
    If you are hesitant to use the same class directly in your workflow, you could also create a new class ZCL_REQUEST_FOR_WF (with the workflow interface), and then simply add your existing class ZCL_WF_REQUEST as an attribute to this new class. Then this new workflow class could include the pure workflow stuff, and your existing class the non-workflow stuff. But this most probably will not make much sense - just implement the if_workflow interface in your existing class (this is just one possibility that you might consider.)
    Regards,
    Karri

  • Services for a New Object

    Helo community:
    We have created a new object ("8C - job family") , this object is a copy of object "C" job,  we have done the customizing, for example in table: T778O and we have filled it with:
    8C     Familia de Funciones     PDOTYPE_C     ICON_ISO_CODE
    So, the question is when we create a new object in PP01, we want to create an attachment, but the options are disabled. Somebody knows how we should enabled these options?.
    Thanks in advance,
    Fabiaa

    Microsoft confirmed I have figured out the answer if you are having
    an issue when your nested cluster breaks when you move your VM guest to the other host...(Below) 
    A nested cluster heartbeat network has to be setup...
    Meaning not only does the nested HB have to communicate between its nodes (classic HB situation), but the HB also has to communicate to each host or communication is lost.
    how to:
    Present a physical nic to both hosts
    Create a new virtual switch for both hosts pointing to the new nics (this will create virtual nics to add to your vm guests)
    This also creates a virtual nic on both hosts (because the physical nic is being presented to hyperv)
    Add nics to both guests in the nested cluster
    Set IP's on all four nics (hosts and guests)
    Creating a subnetted network between all 4 nics (Ping making sure you can communicate all around)
    Now you will be able to fail one member of your nested cluster to the other host without breaking the nested cluster.
    Communication between the host which does not own the guest is the key.

  • Need help for finding objects impacted by size change for an infoobject

    hi all,
    need help for finding objects impacted by size change
    for xxx infoobject, due to some requirements, the size to be changed from
    char(4) to char(10), in the source database tables as well as adjustment
    to be done in BI side.
    this infoobject xxx is nav attribute of YYY as well as for WWW
    infoobjects. and xxx is loaded from infopkg for www infoobject load.
    now that i have to prepare an impact analysis doc for BI side.
    pls help me with what all could be impacted and what to be done as a
    solution to implement the size change.
    FYI:
    where used list for xxx infoobject - relveals these object types :
    infocubes,
    infosources,
    tranfer rules,
    DSO.
    attribute of characteristic,
    nav attribute,
    ref infoobject,
    in queries,
    in variables

    Hi Swetha,
    You will have to manually make the table adjustments in all the systems using SE14 trans since the changes done using SE14 cannot be collected in any TR.
    How to adjust tables :
    Enter the table name in SE14. For ex for any Z master data(Say ZABCD), master data table name would be /BIC/PZABCD, text table would be /BIC/TZABCD. Similarly any DSO(say ZXYZ) table name would be /BIC/AZXYZ00 etc.
    Just enter the table name in SE14 trans --> Edit --> Select the radio button "Save Data" --> Click on Activate & adjust database table.
    NOTE : Be very careful in using SE14 trans since there is possibility that the backend table could be deleted.
    How to collect the changes in TR:
    You can collect only the changes made to the IO --> When you activate, it will ask you for the TR --> Enter the correct package name & create a new TR. If it doesn't prompt you for TR, just goto Extras --> Write transport request from the IO properties Menu screen. Once these IO changes are moved successfully, then the above proceduce can be followed using SE14 trans.
    Hope it helps!
    Regards,
    Pavan

  • New Object Types for Object Links

    Need to create new Object type to object link Product hierarchy from ECC to RPM Item. Field is PRDHA.
    Do we need to create new structure to have the Key linking PRDHA.
    Any suggestions?

    Hi,
    For this, you need to create Key, Proxy class and search field.
    Logically if you use same Proxy class and key as that of PO then the system will search for PO number rather than PR.
    I hope you are clear now.
    Take help of an ABAPer
    Niranjan
    Let me know if it helps !!!

  • Need info for COPA (Cost based profitability analysis)- Archiving objects

    Hi All,
    SAP have introduced new 2 Archiving objects COPAA_xxxx, and COPAB_xxxx instead of the old archiving object COPA1_xxxx.
    Where xxxx = operating concern.
    Can any one please give the document path how to archive the COPA data.
    Means exactly i want the variant parameters for the 2 new archiving objects.
    Please waiting for your reply...
    Thanks,
    Nagendra

    Hi Chandra sekhar,
    I need to Archive the data in R/3 system & ECC6.0 not in BW system.
    I want the steps how to Archive the 2 objects COPAA_xxxx, COPAB_xxxx in ECC6.0 System.
    Please if have any info please help me...
    Thanks,
    Nagendra

  • I need a new power cord for my Mac book Pro its the T type mag connector. I don't need a Tech just a new cord. How do I buy one. The closest Aplle store is 75 miles away and I do not drive.

    I need a new power cord for my Mac book Pro its the T type mag connector. I don't need a Tech just a new cord. How do I buy one. The closest Aplle store is 75 miles away and I do not drive.

    Are you in the US? Order one from here:  http://store.apple.com/us/browse/home/shop_mac/mac_accessories/power?mco=MTM3NjU xNDg
    Or check out Best Buy.

  • I have the G Drive 1 TB (GEN4 1TB) external drive purchased in 2010. I need to connect to my new MacBook Pro. I'm using the external drive for media storage of my video editing projects. Will a 800fw to thunderbolt adapter cable work?

    I have the G Drive 1 TB (GEN4 1TB) external drive purchased in 2010. I need to connect to my new MacBook Pro. I'm using the external drive for media storage of my video editing projects. Will a 800fw to thunderbolt adapter cable work? I understand that using a USB port connection is not fast enough for video editing. I read somewhere the G Drives don't connect well to MacBook Pro.
    thanks
    larry

    I doubt this can be relocated or moved so you might want to just repost in the macbook pro area.
      MacBook Pro
    https://discussions.apple.com/community/notebooks/macbook_pro
    https://discussions.apple.com/community/mac_os?view=discussions
    Can you afford a new Thunderbolt case and cable? any case with FW800 is going to be slow 72MB/sec and less, and any new 1TB drive is capable of 75MB/s minimum up to 125MB/sec.
    Thunderbolt storage can of course when setup properly reach 100's of MB higher using multiple drives.
    Use what you have for a system backup or for secondary backup storage.
    you might be able to take the drive - most cases allow you to open and swap drives - and use this:
    G-Technology 1TB G-DRIVE mini High-Speed Portable Hard Drive                                   
    or this:
    http://store.apple.com/us/product/HB137VC/A/g-technology-4tb-g-raid-professional -high-performance-dual-drive-hard-drive?fnode=5f

  • I have a mixer which i was using with my pc and now i bought a new macbook and it have only one jack for headphones and to use mixers i need jack for microphone too so what should i do

    i have a mixer which i was using with my pc and now i bought a new macbook and it have only one jack for headphones and to use mixers i need jack for microphone too so what should i do

    You need to get headset splitter adapter.
    http://www.startech.com/Cables/Audio-Video/Audio-Cables/35mm-4-Position-to-2x-3- Position-35mm-Headset-Splitter-Adapter-Male-to-Female~MUYHSMFF

  • If I want to put windows7 on my Mac,do I need software for a new comp. or a refurbished?

    If I want to put windows7 on my Mac,do I need software for a new comp. or a refurbished one?

    Mikestoyzz wrote:
    Looking on eBay,the software is labeled for new or refurbished.i'm putting it on through boot camp.
    With my limited knowledge, I don't think that it matters.

Maybe you are looking for