Can someone explain arrays?

What is meant by a program which splits an int array to two arrays: one contains only even numbers, and the other only odd numbers. The two arrays are returned by the split method as array of two arrays, with the first containing only the even numbers and the second containing only the odd numbers.
I understand how to split the int array to two arrays but what is meant by return then by the split method as array of two arrays??
The program example is such below:
class Lab_05
public static void main(String[] args) {
int[] input = {10, 5, 6, 1, 2, 17, 9, 4, 33, 11, 9, 8};
// splits the array into two arrays
int[][] output = split(input);
System.out.print("original: ");
System.out.print(" even: ");
System.out.print(" odd: ");
I understand the above part but what has the below part got to do with anything. What is required of the question? I do not understand...
public static int[][] split(int[] ori) {
However, when the program is run it should look like this:
D:\it1002>java Lab_05
original: 10 5 6 1 2 17 9 4 33 11 9 8
even: 10 6 2 4 8
odd: 5 1 17 9 33 11 9
Can someone be so kind to exaplain to me.. Thanks
Priya

int[][] is an array of arrays (or a multi dimensional array)
public static int[][] split(int[] ori){
is the start of a method definition
it is a public method (other classes can access/ use this method if they have a reference to an Object instance of the class or a reference to the class)
static means that this method does not require an instance (nothing within the method relies on information generated by the program executing, static variables and methods define "constant" values and behaviour)
int[][] means that the result of this method is returned to the calling class in an int[][] (array of arrays of int)
split is the name of the method
(int[] ori) is the parameters that the mehod demands to perform its task (ori is the name that the method will use to reference the data passed to it probably an abbreviation of original, not that abbereviation like this is not really neccessary and only leads to code that is harder to read)

Similar Messages

  • Can someone explain array initi

    alization to me. I am attempting to initialize an array with a 2d array constant full of zeros, then insert data into that array as I measure it using the "insert into array" vi within a while loop. The result output is a 2d array of nothing. Any ideas?

    alization to me. I am attempting to initialize an array with a 2d array constant full of zeros, then insert data into that array as I measure it using the "insert into array" vi within a while loop. The result output is a 2d array of nothing. Any ideas?Using "Build Array" is very inefficient and gives a big performance hit.
    That's why people do it this way when necessary.
    The initialisation is screwed. You don't initialise the shift register with
    an empty array, you initialise the shift register with an array that has
    been initialised to the required dimension using the "initialise array"
    node. As someone else has pointed out, you need to use "Replace Array
    Element" and NOT "Insert into array". Using the latter as you have done has
    the same drawbacks as using "Build Array" in that all the existing data has
    to be copied to a new array each time you add new data. The "replace array
    element" will only replace existing elements- if you try and replace an
    element that doesn't exist then n
    othing happens. So obviously in the
    attached example where nothing initially exists, nothing will ever happen.
    Also, when you do things this way, you need logic to wrap the counter back
    to the start when the end of the array is reached to implement a circular
    buffer- else your counter just keeps going up indefinitely and runs off the
    end of the array. In Labview this does nothing. In other less forgiving
    languages it will cause a crash. If you don't want a circular buffer, you
    need to stop the loop when the iteration counter is equal to or exceeds the
    number of elements with which the array has been initialised.
    I've attached a modified version of the example.
    njh wrote in message
    news:[email protected]...
    > Use build array!
    > If you don't need iteration number.
    > "Tomcat" wrote in message
    > news:[email protected]...
    > > Thanks for your suggestion. I have attached a vi that show what I am
    > > trying to accom
    plish. It works perfectly the first time and not at
    > > all after that. Any suggestions?
    >
    >
    >
    [Attachment stream_to_array.vi, see below]
    Attachments:
    stream_to_array.vi ‏27 KB

  • Can someone explain how .prel files work?

    Can someone explain how .prel files work?  My C drive is O/S and programs, my D drive is storage and the project file(s) (the .prel file) are on my E drive. 
    How is this supposed to be more efficient/faster?  P.E. (C drive) has to constantly communicate back and forth across drives with the .prel file and all the files in the subfolders?  It seems like it would be slower. 
    As I mentioned in a previous post; my zooms in/out of the Timeline are VERY slow.  It is almost 1 second before the Timeline gets bigger/smaller.  Any info would be great,thanks!
    Elwood
    Windows 7 64 bit, i7 980x @333 6 core processor, 12 GB ram DDR 1600, Radeon 5850 GPU PE 9

    By using multiple HDD's, one is spreading the I/O (Input/Output) load over various HDD's. The controller is faster than a single HDD, being tasked to read/write from/to multiple places. One of the first laws of physics is that an object cannot be in more than one place, at the same time. The heads on a HDD are no different. If requests for multiple reads are made, the heads will position themselves over on place on the platters, read, and then move to the next requested location, and so on. However, with multiple HDD's, and a good, fast controller, the heads of each HDD will be placed, where necessary, so reads are done at once, from multiple locations.
    For ultimate performance, a good setup would be as follows:
    C:\ system OS and programs (more reading being done here, than writing)
    D:\ Project files (PREL's in this case)
    E:\ RAID 0 Scratch Disks for Media Cache, but not Render files (both reading and writing)
    F:\ RAID 0 Media files (more reading, but also writing)
    G:\ RAID 0 Export/Share and Render files
    Some go so far as to separate out Audio Assets from Video Assets, and use a separate RAID 0 for each
    The downside of that "ultimate performance" setup, is that when a Project is completed, to clean up, one has to go to many HDD's, and locations. There can also be issues when Archiving a Project, because things are scattered about.
    I get "good performance" by having my Project, Copies of my Assets and all Scratch Disks on one HDD. What I give up in performance, I make up for with housekeeping chores, when the Project is done. I still spread my OS/programs from my Projects, with separate physical HDD's.
    Good luck, and hope that this helps,
    Hunt
    PS - Above, I mention RAID 0, but even greater speed can be achieved via many HDD's in the Array, and perhaps a RAID 50. RAID 0 is just two physical HDD's. Also, for RAID, I recommend a dedicated RAID controller card, and NOT software, or the MoBo's RAID capability.

  • I have just downlaoded the color burst app, can someone explain how to use it?

    I have just downlaoded the color burst app, can someone explain how to use it??
    There is no help in the app and i can't log onto the smart solutions..it is really frustrating me because it is propably a really simple app...can someone please help???

    I posted in this thread an example that illustrates how to use the 3d graph to do surfaces ac lines.
    The type of data that you present to the 3d graph depends on which mthod you are using. In general you want to present a set of points that need plotted. These points are defined by taking one value for each of the XYZ and sometimes W arrays.
    Explanation:
    You want to plot a surface that is defined by four point (X0,Y0,Z0,W0), (X1,Y1,Z1,W1), etc. You can present the values using (4) 2-d arrays each of which have four values at index (o,o), (0,1), (1,0) and (1,1).
    Thie first point plotted would be the point that is defined by taking (0,0) from each of the arrays.
    So as you can see from the above all of your arrays should be of the same size and dimensions for this to work.
    Look at the Example i posted in the other thread and try some small experiments with small data sets before you jump to anything complicated.
    I hope that helps,
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Can someone explain how to set up an administrator account so that I can have my phone and my daughters have separate apple ids?

    I mistakenly updated to the latest version of iOS and ever since then I can send messages to my daughter and I receive them but she does not.  She has an iphone also and her phone is under my apple id also.  Someone told me that I could set up an Administrator Account so that she can still be under my account but she has her own ID and that will fix the problem with text/imessages.  I can't find anything on the website that explains how to do that.  Can someone explain that to me?
    Thanks!

    I'm still not clear on what you are trying to accomplish. If you have an iPhone and she does as well you should have your own Apple IDs.
    If you want to pay for any purchases she makes with her phone as far as apps/music goes than that is what Family sharing is for.
    In my case my Wife and I are setup for family sharing. When she purchases music/apps it charges my credit card. This setup also allows me to share my past music/app purchases with her and vice versa.

  • Please can someone explain how to delete email addresses?  I have people who when I type in their name it comes up with the correct email address but then when you hit return to confirm it promptly changes the name to someone else (always the same someone

    Please can someone explain how to delete and email address that when typed in brings up one name but when you hit return to confirm it jumps to another name.  I can't find them in my contacts list but they do come up when you type the first few letters of a name.
    EG If I type xyz and the name of the person comes up, when I press return to confirm that's the one I want then it jumps to [email protected],  always the same def address.
    I can't fathom it out.
    Thanks
    Terri

    Try this:
    Start a new email.  In the To address bar, type in xyz like you normally do, press return to confim, and when the address you want to remove shows up in the address bar, move your cursor over the address you want to delete.
    A small triangle next to the name will show up.  click on it, a drop down menu will open, click Remove from Previous Recipients List.  Then do the drop down menu again and Remove Address.
    Good luck.

  • I cannot find a way to sort the bookmark folders themselves alphabetically by name.I am not talking about in a view mode but in the way they are displayed when I click on my bookmarks tab. Can someone explain to me how to accomplish this.

    I have a lot of various book mark folders with websites contained within each folder. I am able to sort the websites within each folder alphabetically by name but I cannot find a way to sort the bookmark folders themselves alphabetically by name.I am not talking about in a view mode but in the way they are displayed when I click on my bookmarks tab. Can someone explain to me how to accomplish this other than manually dragging them as this is extremely hard for me due to the fact that I am a quadriplegic with limited hand movement dexterity

    Bookmark folders that you created are in the Bookmarks Menu folder. "Sort" that folder.
    http://kb.mozillazine.org/Sorting_bookmarks_alphabetically

  • Trying to understand RSTP - Please can someone explain this?

    Hi Group
    I am still confused about how RSTP is implemented. From what i understand the major difference is that STP
    used Timers for Loop prevention whereas RSTP coordinates between neighbors via messages (proposal/aggreement) to turn on links
    more quickly after topology changes and is "timer free".
    However, I have not noticed any difference in the configuration from the legacy STP
    configurations and the RSTP configuration on cisco devices. Or are there any differences??
    I have read in documentation that RSTP natively includes features like UplinkFast, BackboneFast and PortFast. So are these features now obsolete
    and not needed to be configured if you are running RSTP. (Although i have seen Portfast still configured along with RSTP on many switches)
    Also can someone explain the below Points from Cisco Documentation
    1) should STP be disabled on edge ports all together as suggested below?
    "STP edge ports are bridge ports that do not need STP enabled, where loop protection is not needed out
    of that port or an STP neighbor does not exist out of that port. For RSTP, it is important to disable STP
    on edge ports, which are typically front-side Ethernet ports, using the command bridge
    bridge-group-number spanning-disabled on the appropriate interface. If RSTP is not disabled on edge
    ports, convergence times will be excessive for packets traversing those ports."
    2) It seems RSTP relies on duplex setting to determine inter-switch links. What is the configuration to explicitly
    configure RSTP link types? (I couldnt find this in the documentation)
    "RSTP can only achieve rapid transition to the forwarding state on edge ports and on point-to-point links.
    The link type is automatically derived from the duplex mode of a port. A port that operates in fullduplex
    is assumed to be point-to-point, while a half-duplex port is considered as a shared port by
    default. This automatic link type setting can be overridden by explicit configuration. In switched
    networks today, most links operate in full-duplex mode and are treated as point-to-point links by RSTP.
    This makes them candidates for rapid transition to the forwarding state."
    Also i am a bit rough on my RSTP knowledge even after skimming a few Cisco documents. Can someone please explain this in simple way.
    Thanks in advance

    to configure it on a device:-
    spanning-tree mode rapid-pvst
    PortFast/UplinkFast & BackboneFast were cisco "Enhancements" to 802.1d STP. RSTP just incorperates them. If you want to configure portfast, the command is still "spanning-tree portfast"
    OK
    1) That is your choice - I have bitter experiance of users/IT admins just plugging hubs/switches in when ever they can. Also cabling the switch back to itself creating a cabled loop. So my advice to you is to leave STP enabled on all switch ports, BUT enable BPDUGuard - this is a life saver, if you have configured portfast.
    2) duplex auto! or duplex full (overiding)
    I really suggest that you read the 802.1d standard, once you understand normal spanning-tree - RSTP will come to you.
    http://www.cisco.com/en/US/tech/tk389/tk621/tsd_technology_support_protocol_home.html')">http://www.cisco.com/en/US/tech/tk389/tk621/tsd_technology_support_protocol_home.html')">http://www.cisco.com/en/US/tech/tk389/tk621/tsd_technology_support_protocol_home.html')">http://www.cisco.com/en/US/tech/tk389/tk621/tsd_technology_support_protocol_home.html
    http://en.wikipedia.org/wiki/Spanning_tree_protocol')">http://en.wikipedia.org/wiki/Spanning_tree_protocol')">http://en.wikipedia.org/wiki/Spanning_tree_protocol')">http://en.wikipedia.org/wiki/Spanning_tree_protocol
    HTH>

  • Can someone explain me this?

    Can someone explain me why LabVIEW embeds the graphic in sheet 1 if i specify location as "prueba"? The vi is for LV 5.0.1f1 and Excel 2000, it just creates a workbook, adds some data and creates a chart. I've tried to ask a NI engineer but i receive no answer.
    Thanks,
    Gorka
    Attachments:
    Untitled.llb ‏430 KB

    Hi Gorka,
    I am not sure if this helps but the help file for the add Sheets method says
    "Add Method (Sheets Collection)
    Creates a new worksheet, chart, or macro sheet.
    Syntax
    expression.Add(Before, After, Count, Type)
    expression Required. An expression that returns a Sheets object.
    Before Optional Variant. An object that specifies the sheet before which the new sheet is added.
    After Optional Variant. An object that specifies the sheet after which the new sheet is added.
    Count Optional Variant. The number of sheets to be added. The default value is one.
    Type Optional Variant. Specifies the sheet type. Can be one of the following XlSheetType constants: xlWorksheet, xlChart, xlExcel4MacroSheet, or xlExcel4IntlMacroS
    heet. The default value is xlWorksheet.
    Remarks
    If Before and After are both omitted, the new sheet is inserted before the active sheet.
    *******" (I added asterisks for emphesis).
    the help for the "location method" says,
    "Add Method (Sheets Collection)
    Creates a new worksheet, chart, or macro sheet.
    Syntax
    expression.Add(Before, After, Count, Type)
    expression Required. An expression that returns a Sheets object.
    Before Optional Variant. An object that specifies the sheet before which the new sheet is added.
    After Optional Variant. An object that specifies the sheet after which the new sheet is added.
    Count Optional Variant. The number of sheets to be added. The default value is one.
    Type Optional Variant. Specifies the sheet type. Can be one of the following XlSheetType constants: xlWorksheet, xlChart, xlExcel4MacroSheet, or xlExcel4IntlMacroSheet. The default value is xlWorksheet.
    Remarks
    If Before and After
    are both omitted, the new sheet is inserted before the active sheet.
    Just trying to help,
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • CAN SOMEONE EXPLAIN ME THE DISPLAY QUALITY

    I have just purchased a new macbook pro 15" 2.4ghz. Im a designer, i havent even created my appleid, im on my sisters... i made a sacrifice to buy this $2700 laptop.
    and Im so dissapointed...
    I CANT SEE SMOOTH GRADIENTS.. all i see are ugly lines... i dont get it, for such a high class LAPTOP.
    Apple support please help me solve this. ive been reading forums about 6bit screens for this laptop.. i dont want to believe that. can someone explain? im returning this...

    I can verify that all of Apple's laptops use 18 bit (6 bits per Red, Green Blue) color, which is about 260,000 colors. The OS then using dithering to fake the missing colors. Despite what you have read, they are incapable of 24 bit 'millions of colors'.
    The problem with this argument is that, when it comes down to it, the color displays are made up of dithered red, green, and blue elements anyway. We accept that this form of display gives us "full color", so it's difficult to argue that millions of colors can't be represented using the same mechanism. It's not quite 16.7 million (more like 16.3 or something) but Apple's text has always taken care to read "millions of colors" rather than 16.7 million (which you'll still see on the specifications for the Cinema displays).
    Just for informational sakes though, these kinds of 6-bit displays don't rely on OS spatial dithering; they actually make use of their very fast switching to perform temporal dithering, switching a pixel between two shades very quickly to generate an in-between shade. That's why for most people the result is usually visually indistinguishable from true 8-bit color, and doesn't look like what you'd see with traditional dithering.
    If the OP is noticing severe banding on gradients, it's more likely to be an issue with color profiles than with the display being 6-bit.

  • Can someone explain European use of 3G in a new iPad?

    Can someone explain European use of 3G in a new iPad? Will it work in Europe? I am concerned.
    Will the keyboard, charger, case, dock from iPad2 work with the new iPad?

    yeah everything apart from LTE(4G) and the charger itself (if you buy it USA) will work

  • Can someone explain the use of a hashtable in java?

    can someone explain the use of a hashtable in java?

    Hashtable allows us to store values along with keys.
    One other advantage is, it provides Synchronised methods.
    Hope you got it.

  • I am getting cross border fee charges on my credit card that I believe to be assessed against my monthly fee, can someone explain?

    I am getting cross border fee charges on my credit card that I believe to be assessed against my monthly fee, can someone explain?

    This is an open forum, not Adobe support... you need Adobe staff to help
    Adobe contact information - http://helpx.adobe.com/contact.html
    -Select your product and what you need help with
    -Click on the blue box "Still need help? Contact us"
    -or by telephone http://helpx.adobe.com/x-productkb/global/phone-support-orders.html

  • Can Someone Explain the order of things Using Swingworker?

    Hi:
    Can someone explain very clearly the order of things using Swingworker? Please do not refer the SUN tutorials. I am totally dead in the water with a very large application and the order of things is not sensible. Also, if the worker thread is too long, the GUI gets updated, but my progress bar (killed right after in the finished method) remains running in some instances only.
    Can someone explain any debugging methods for thread work?
    I am a veteran programmer of 19 years and this one's got me. The event dispatch thread returns immediate, the GUI responds well, but the progress bar setVisible(false); ... just after in the finished() method (on Event Dispatch thread) does not go away, continues running, only on very long (large query) work. I'm truly stumped. I have successful applications of the Swingworker use, the progress bar, and everything works fine. Not this one.
    Debugging threads is what I need. Or some tool that visually shows threads as the program runs.
    Thanks for any help,
    PiratePete

    Thanks. I guess I should count my blessings when using free stuff. But I have been impressed with what the J2SDK has to offer. I have been writing a complicated application that I am going to market and most of my problems have been "design" in nature.
    Thanks again,
    PiratePete

  • Can someone explain the hyperthreading settings in cmos (the 4x,5x, etc.)?

    Someone once said admitting you don't know something is the first step on the road to knowledge....or something like that 
    Can someone explain the hyperthreading setting in the CMOS Setup - mine is set to 5x, which I think is correct for my cpu - Venice 3500+, but I don't really know what it does.  What does that setting affect?  I think it was 4x by default, until I loaded optimal settings, and it went to 5x.....

    HT = Hyper Transport
    Q: What is HyperTransport™ technology?
    A: HyperTransport™ technology is a new high speed, high performance point-to-point link for interconnecting integrated circuits on a motherboard. It can be significantly faster than a PCI bus for an equivalent number of pins. HyperTransport was previously codenamed Lightning Data Transport, or LDT. HyperTransport technology was invented by AMD and perfected with the help of several partners throughout the industry. It is primarily targeted for the IT and Telecomm industries, but any application where high speed, low latency and scalability is necessary can potentially take advantage of HyperTransport technology. HyperTransport technology was invented in order to unleash the tremendous power of the AMD microprocessors. HyperTransport is planned to bring the computation experience to a  new level.
    Hyperthreading Technology used by Intel.

Maybe you are looking for