How to set the array size

Hi,
below is my sample code
class test
int sample[][]=new int[10][10];
int rows=0,k=0;
int columns=0;
public void meth()
rows=9;
columns=9;
}//end of meth()
public meth_2()
for (int i=0;i<rows;i++)
for(int j=0;j<columns;j++)
sample[i][j]=k;
k++;
for (int i=0;i<rows;i++)
for(int j=0;j<columns;j++)
System.out.println(sample[i][j]);
}//end of meth_2()
public int[][] getList()
return sample;
}//end of classNow that my question is, i need to set the size of array sample[][] to sample[rows+1][columns+1].. but to do so, 'rows' and 'columns' values will only be generated upon the execution of method meth() . I need sample[][] array to be declared right after the class begins. The values that are returned from sample[][] array through that getList() method is been used in another class.. So how do i set the size of sample[][] array to
int sample[][] = new int[rows+1][columns+1];Any response is highly appreciable.
Thanks in advance
Edited by: netbeans2eclipse on Sep 14, 2008 1:20 PM

It seems you answered your question yourself ;-)
Just split this:
int sample[][] = new int[rows+1][columns+1];in two parts.
Declaration:
int sample[][];and instantiation in meth() or meth_2():
sample = new int[rows+1][columns+1];

Similar Messages

  • Hi, I am using Indesign CS6, How to set the page size in Inches.

    Hi, I am using Indesign CS6, How to set the page size in Inches.

    All fields in InDesign can be entered in any measurement system. So, if you want to make an 8"x10" document and go to File>New Document and the window looks like this:
    …you can type either 8 in or 8" into the Width field like this:
    …and when you move to the next field, it will convert the eight inches into the equivalent number in the unit of measure that it is using at the moment, like this:
    … (203.2 milimeters is the same as 8 inches). You can also enter a different measurement unit into other fields once the file is created, such as the width or height of a frame, or the position of an object in the X and Y coordinates.
    If you would rather just work in inches instead of having to type the inches mark or abbreviation, go to InDesign>Preferences>General and select the Units & Increments tab. There you will see Ruler Units for Horizontal and Vertical at the top of the window. Set them to Inches and all of the fields will display in inches. If you do that to an open document, you will change the unit of measure for that document. If you do it while no documents are open, it will change the unit of measure for any new documents you create. To change the unit of measure for existing documents, you will have to open each and make the change.

  • How to set the screen size with nested Iview screen

    Can someone show me how to set the screen size with nested IView  screen.
    at the moment i only try it with trial and error untill it looks somewhat close. Is there a property in VC to set the size for Height and width.
    The same question is for the form. the form elements inside the form is easy but the actual form is still a challenge.

    Hi,
    Yes you are correct ,Still the Form and iview are not able to change thier Layout Structure using a Propery.
    it is available with VC7.1
    Govindu

  • How to set the frame size?

    Hi,
    Can some one show me how to set the frame size in this program? History: I have created a window and added a button but its to small. So I want to increase the size of the frame to at least 600X400 pixel.
    private static void showGUI() {
            //Create and set up the window.
            JFrame frame = new JFrame("ButtonDemo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Create and set up the content pane.
            Main newContentPane = new Main();
            newContentPane.setOpaque(true); //content panes must be opaque
            frame.setContentPane(newContentPane);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        }It would be nice if you could show me how to do it.
    Thank you very much for reading this.

    Challenger wrote:
    Simply adding
    frame.setSize(new Dimension(600,400));to the end of your code should work perfectly.Or, if you want to do it correctly, .setPreferredSize() on your frame before you .pack() it. The default layout manager for JFrame is BorderLayout, which uses the preferredSize of each component to calculate sizes during the .pack() call.

  • How to set the page size

    Hi,
    How to set the page size of a B tree node in berkeley db java edition?
    thanks.

    The two systems have different performance characteristics. If you are concerned with the performance characteristics, then the best way to tell is to benchmark them.
    By the way, both BDB and BDB JE are B-trees.

  • How to set the Font size of Label?????

    Hello everyone.
    I want to knoe how to set the Font size of the Label???
    Please help..
    Thanks a lot.
    Gloria

    Label myLabel = new Label("Hello World");
    //Font(String name, int style, int size)
    myLabel.setFont(new Font("Arial", Font.PLAIN, 12));

  • How to set the minimum size of the JDialog.

    Hi Could any one tell me ,
    How to set the minimmum size of the JDailog.
    I am using the JDialog's setMinimumSize(...)
    But it is not working.....
    Regards -
    Vikas Kumar sahu

    That's pretty much all there is, although you could always add a componentlistener and manually not let the size go below your minimum.
    Or you could try overriding setSize...

  • How to set the heap size of JVM

    please let me know that how to set the heap size of JVM

    C:\>java -X
        -Xmixed           mixed mode execution (default)
        -Xint             interpreted mode execution only
        -Xbootclasspath:<directories and zip/jar files separated by ;>
                          set search path for bootstrap classes and resources
        -Xbootclasspath/a:<directories and zip/jar files separated by ;>
                          append to end of bootstrap class path
        -Xbootclasspath/p:<directories and zip/jar files separated by ;>
                          prepend in front of bootstrap class path
        -Xnoclassgc       disable class garbage collection
        -Xincgc           enable incremental garbage collection
        -Xbatch           disable background compilation
        -Xms<size>        set initial Java heap size
        -Xmx<size>        set maximum Java heap size
        -Xss<size>        set java thread stack size
        -Xprof            output cpu profiling data
        -Xrunhprof[:help]|[:<option>=<value>, ...]
                          perform JVMPI heap, cpu, or monitor profiling
        -Xdebug           enable remote debugging
        -Xfuture          enable strictest checks, anticipating future default
        -Xrs              reduce use of OS signals by Java/VM (see documentation)look at the -Xm? lines
        -Xms<size>        set initial Java heap size
        -Xmx<size>        set maximum Java heap sizeThis can be used e.g. like this:java -Xms8M -Xmx32M MyProgwhich runs MyProg in a java VM with the initial heap size of 8 MB and a maximum heap size of 32 MB.
    - Marcus

  • How to set the fix size jframe window

    when I run the jframe ,the jframe window size is very small
    1)how to set the fix size jframe window??
    2)how to set the jframe cannot change the window size??
    thx~~

    1. You can set the size by calling JFrame's method setSize. There are two versions of this method: (1) setSize(int width, int height) and (2) setSize(Dimension d). Note, that when you use this method to set the frame size, you don't have to call JFrame's pack method.
    2. JFrame has a method called setResizable(boolean resizable) which you can call with the argument false.
    Without any ill intent, these questions are regarding something that is very easily answered by looking at the documentation for the JFrame class. I suggest to anyone working with swing to at least look briefly through the base classes they're extending before giving up. In my experience it is always more gratifying to figure things out on my own than asking someone. But please don't take this the wrong way, I respect people who seek out help in order to further their knowledge, instead of just giving up.

  • How to set the stack size for alchemy application?

    Anybody know how to set the stack size for alchemy application?
    If you know, please tell me how to adjust the stack size for alchemy application?

    Hi,
    The stack size is set as public const gstackSize in the alchemy generated code.  You can see this if you build with ACHACKS_TMPS set.  The default is one megabyte.
    One way to change the stack size is to use llvm-dis to disassemble avm2-libc/lib/avm2-libc.l.bc, generating avm2-libc.l.ll, modify the constant, and then use llvm-as to recompile your modified library and overwrite the old one.  These utilities should be in your path if alchemy is set up.

  • How to Set the Paper Size in Smart Forms

    Hi Friends,
                     I need to SET the Paper Size to default A4 in a smart form...and in some other case we need to set to other type 8.5 X 11...How can i set it....?

    Moving this discussion to the Scanning & OCR forum.

  • How to set the paper size when printing to postscript...

    I need help in setting the paper size in the PrintPreference when using either the Postcript File or Adobe PDF printer to generate ps files.
    Here's what I am doing (in c++) and I seem to be getting only 8.5x11 no matter the document page size:
    LPDISPATCH p_Dispatch = Document.DocumentPreferences();
    p_Dispatch = Document.DocumentPreferences();
    if(p_Dispatch)
    DocPreference docPreference(p_Dispatch);
    pgOrientation = (idPrintPageOrientation)docPreference.get_PageOrientation();
    pageW = docPreference.get_PageWidth();
    pageH = docPreference.get_PageHeight();
    paperSize = docPreference.get_PageSize();
    docPreference.ReleaseDispatch();
    p_Dispatch = Document.PrintPreferences();
    if (p_Dispatch)
    { PrintPreference printPreference(p_Dispatch)printPreference.SetPrinter(idPostscriptFile);
    printPreference.PrintFile(outfile);
    printPreference.SetPaperSize(paperSize ); /*I have also tried idCustom but it crashes with invalid parameter for the object type.*/
    printPreference.SetPaperWidth(pageW);
    printPreference.SetPaperHeight(pageH);
    VARIANT vprinterPresetType;
    vprinterPresetType.vt = VT_I4;
    vprinterPresetType.lVal = CInDesignApplication::idCustom;
    Document.PrintOut(FALSE, vprinterPresetType);....
    So how do i pas the document paper size to the print preset or preference?
    I appreciate your input.

    Moving this discussion to the Scanning & OCR forum.

  • How to set the Range size dynamically in an Iterator?

    Hi,
    One of my scenrio, i read the range size of Iterator and i performed the business logic validation. But in my case, range size is changed as per business requriement for a paricular Iterator.
    Is it possible to set the Range size property dynamically in an Iterator of pageDef File.
    I'm using JDeveloper 11.1.1.3.0
    Can anyone help me regarding this???
    Thanks & Regards,
    Perumal S

    Good afternoon,
    This works: f?p=1:#MYPAGENUMBERCOLUMN#::Session:Request:Debug:Clearcache:itemname:itemvalue:printerfreindly
    It works very well. I have been struggling for a couple of hours trying to figure out how to calculate the page number I wanted to link to from a report column defined as a linked item. I ended up modifying my VIEW to include the page number for that particular type of data and use this technique to jump to the correct page.
    Thanks for posting this. Nothing else seems to work.
    Don.

  • How to set the cell size in a JFrame

    Hello. Is there any way of setting the cell size in a JFrame. The reason why I want to set the cell size is that I want to be sure of their location that when I am placing components on the JFrame. So is there any way of setting the cell size beforehand. Also for the following code.
    JFrame frame = new JFrame("Window");
    frame.setSize(100,100);is the size 100 by 100 is he size of the cell?

    smithbrian wrote:
    When I am placing a component on the grid I want to be sure the component is exactly where I place it. In order to do that I would need to know what is the size of the gird and how to change the size of the gird in the JFrame.What grid?? You're assuming that we know much more about your program than we actually do. We actually know zip. Please read this help site which will help you to avoid similar errors in posting questions here. It has helped me in the past: [smart questions|http://www.catb.org/~esr/faqs/smart-questions.html]

  • How to set the font size on only one object!

    I wonder how i could programmatically set the font size on only one object?
    Igor Stojčević

    Hello,
    You can use the builtin SRW.SET_FONT_SIZE
    http://www.oracle.com/webapps/online-help/reports/10.1.2/topics/htmlhelp_rwbuild_hs/rwrefex/plsql/builtins/srw/srw_set_font_size.htm
    in the Format trigger
    http://www.oracle.com/webapps/online-help/reports/10.1.2/topics/htmlhelp_rwbuild_hs/rwrefex/plsql/triggers/tr_format_trigger.htm
    Regards

Maybe you are looking for

  • Bean is not working in jsff

    hi All i developed 4 .jsff fragments and i have included in jspx page . i created one bean with 4 variable and i crated datacontrole for the same bean . when i am mapping these variables with components which are in .jsff fragments . the values are n

  • Discontinuation functionality with production orders

    Dear Guru's, Can anyone please confirm: is the functionality for discontinuation of a material (including follow-up material) not available with production orders? Example: in our system we have component A that is followed up by component B. This is

  • How do I highlight a pdf document?

    I have downloaded a pdf file from the internet to my files.  I want to share it with a friend; but I want to highlight parts of the text first.  I have read the acrobat article which says highlighting can be done with adobe reader.  Also, highlightin

  • How to reset junk mailbox message count?

    Apologies if this is resolved elsewhere, but I can't find it. For the past several months I have received several "ghost" spams per day. (There is nothing in the sender, message header, or body.) The mail filter does not catch them. I wrote a rule (b

  • Problems with template

    I have made some changes in my Template file ( dwt) and normally then i save it, it ask for update changes in all other files build on this template, but not after I have upgrade til Dreamweaver CS3 - Why ? Have I the possibility to force this action