How to solve these errors??

This program splits an int array to two arrays: one containing 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.
The source code:
class OddEven
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: " + input.length);
for (int i = 0; i < input.length; ++i) {   
if ( i % 2 == 1);
System.out.print(" even: " + i);
if ( i % 2 == 0);
System.out.print(" odd: " + i);
public static int[][] split(int[] ori) {
int i,even = 0,odd = 0;
// The result is a 2d array with result[0] containing even nos and result[1] containing odd nos
int result[][];
for(i = 0; i < ori.length; ++i){
// Even
if( ori[i] % 2 == 0) {
result[0][even] = ori;
even++;
else
// Odd
result[1][odd] = ori[i];
odd++;
return result;
This is what i should get when it is run.
D:\> OddEven
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
However i get these 3 errors:
1. variable result might not have been initialised
result[0][even] = ori[i];
2. variable result might not have been initialised
result[1][odd] = ori[i];
3. missing return statement
public static int[][] split(int[] ori) {
I do not know how to rectify these errors. Can anyone help me please! Thanks

The subject matter seems very familiar...
However i get these 3 errors:
1. variable result might not have been initialised
result[0][even] = ori;
2. variable result might not have been initialised
result[1][odd] = ori[i];
it's due to the fact that result[][] may have been declared, but the actual array(s) not created, hence the accesses would cause problems.
just declare as follows :-
int[][] result = new int[X][Y];
where X, Y are the number of elements in each.
3. missing return statement
public static int[][] split(int[] ori) {If you really don't know the answer to this one, then give up. The error message clearly indicates the problem, and if you have to ask people something which is very, very basic Java...

Similar Messages

  • How to solve these Errors when generating .dll (using JNI) ?

    Hello,
    I am very new about JNI. As I have been trying to generate my dll (sysHook.dll) as I followed this topic http://forums.sun.com/thread.jspa?threadID=632369 (by Jbgohlke ) by putting this command:
    cl -I"C:\Program Files\Java\jdk1.6.07\include" -I"C:\Program Files\Java\jdk1.6.07\include\win32" sysHook.cpp -FesysHook.dll Then many errors are popped up as follows:
    sysHook.obj :error LNK2019: unresolved external symbol __imp__CallNextHookEx@16 referenced in function "long__stdcall HookKeyboardProc(int,unsigned int,long)" (?HookKeyboardProc@@YGHIJ@Z)
    sysHook.obj :error LNK2019: unresolved external symbol __imp__SetWindowsHookExA@16 referenced in function " void__cdecl Init(void)" (?Init@@YAXXZ)
    sysHook.obj :error LNK2019: unresolved external symbol __imp__UnHookWindowsHookEx@4 referenced in function "void__Cleanup(void)" (?Cleanup@@YAXXZ)
    sysHook.dll : fatal error LNK1120: 3 unresolved externals
    If anyone of you know this PLEASE!! point me out!!
    [email protected]
    Thanks in advance

    Specify the appropriate library when linking.
    This is not a JNI question. It is a Windows/C/C++ programming question.
    Locking this thread.

  • How to solve the Error in Action for illustrator cs3

    Through action in illustrator cs3 i changed the document mode RGB to CMYK via Visual Basic. But sometimes it throws 2 different kinds of error messages.
    CODE:
    appRef.DoScript "Change", "Convert"
    While (appRef.ActionIsRunning)
    WScript.sleep 1000
    Wend
    Error 1:
    Could not complete the Play Command because the action is playing.
    Error 2:
    The Object "Document Color Mode: CMYK Color" is not currently available.
    Could you please explain how to solve this error.

    The input data provided as the first argument to ore.tableApply and rqTableEval are physically being moved from Oracle Database to the database server R engine, and then serially operating on the entire table  The benefit to using ore.tableApply/rqTableEval in this case is the potentially greater amount of RAM on the database server.  But it's important to note that R’s memory limitations still apply in this case.
    You may have already seen the blog post on Managing Memory Limits and Configuring Exadata for Embedded R Execution where we discuss setting memory limits for the database server R engine. These suggestions can be used to load reasonably sized data tables, and you may still encounter limitations when using a very large table.
    In contrast to the "table apply" functions, the "group Eval" and "row eval (" functions are parallel-enabled embedded R execution functions. They support data-parallel execution, where one or more R engines perform the same R function, or task, on different partitions of data. The following training and blog links should be helpful in choosing the correct function for your use case:
    http://www.oracle.com/technetwork/database/database-technologies/r/r-enterprise/learnmore/ore-1-4-embedded-r-execution-s…
    http://blogs.oracle.com/R/entry/invoking_r_scripts_via_oracle1
    http://blogs.oracle.com/R/entry/invoking_r_scripts_via_oracle2
    http://blogs.oracle.com/R/entry/invoking_r_scripts_via_oracle3
    http://blogs.oracle.com/R/entry/invoking_r_scripts_via_oracle4
    http://blogs.oracle.com/R/entry/invoking_r_scripts_via_oracle5
    Sherry

  • How to solve this error JBoss Server start time............

    How to solve this error JBoss Server start time............
    10:45:38,484 INFO [TomcatDeployer] deploy, ctxPath=/JobWorkInvoice, warUrl=.../deploy/JobWorkInvoice.war/
    10:45:38,640 ERROR [STDERR] log4j:ERROR A "org.jboss.logging.util.OnlyOnceErrorHandler" object is not assignable to a "org.apache.log4j.spi.ErrorHandler" variable.
    10:45:38,640 ERROR [STDERR] log4j:ERROR The class "org.apache.log4j.spi.ErrorHandler" was loaded by
    10:45:38,640 ERROR [STDERR] log4j:ERROR [WebappClassLoader
    delegate: false
    repositories:
    /WEB-INF/classes/
    ----------> Parent Classloader:
    java.net.FactoryURLClassLoader@d5f9b9
    ] whereas object of type
    10:45:38,640 ERROR [STDERR] log4j:ERROR "org.jboss.logging.util.OnlyOnceErrorHandler" was loaded by [org.jboss.system.server.NoAnnotationURLClassLoader@5d173].
    10:45:38,687 ERROR [STDERR] log4j:ERROR Could not create an Appender. Reported error follows.
    10:45:38,687 ERROR [STDERR] java.lang.ClassCastException: org.jboss.logging.appender.DailyRollingFileAppender
    10:45:38,687 ERROR [STDERR]      at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:174)
    10:45:38,687 ERROR [STDERR]      at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:149)
    10:45:38,687 ERROR [STDERR]      at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:162)
    10:45:38,687 ERROR [STDERR]      at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:424)

    The error message suggests that your system is running out of memory. How much memory is available for OC4J on this box?
    You may also see problems like these when any of the following Jar files in your classpath :
    <li>$OH/jlib/repository.jar
    <li>$OH/j2ee/home/jazn.jar
    <li>$OH/j2ee/home/oc4j.jar
    <li>$OH/j2ee/home/jazncore.jar
    <li>$OH/jlib/infratool.jar
    Thanks,
    EJ

  • How to solve itunes error code 0xE8000012?

    how to solve itunes error code 0xE8000012?
    These error make mine itunes cannot detect mine iphone 4
    my iOS version is 5.1.1
    Please i really need some solution to solve this problem
    Urgent Thanks!! 

    howdy tej prakash,
    you may want to look at this thread ...
    - Error -9812 and -1202: Apple Support Communities
    https://discussions.apple.com/thread/2153674?start=0&tstart=0
    i got that from a search for "itunes error 1202". [*grin*]
    take care,
    lee

  • How to solve this error java.util.MissingResourceException

    Hi Friends,
    I had developed one web dynpro application by using  Internationalization - I18N of WebDynPro (Java)  Application (Blog)   but I got one error that is
    <b>java.util.MissingResourceException: Can't find bundle for base name com.sap.example.language.lang, locale en_US</b> 
    Actually i created two properties file
    1. lang_en.properties
    2. lang_ta.properties
    I stored this two properties file in this package com.sap.example.language
    and this my code in DOInit()
    sessionLocale =  WDClientUser.getCurrentUser().getLocale();
    resourceHandler = ResourceBundle.getBundle("com.sap.example.language.lang",sessionLocale);
         catch (WDUMException e)
         e.printStackTrace();
         wdContext.currentContextElement().setUsername_label(resourceHandler.getString("testview.username"));
         wdContext.currentContextElement().setPassword_label(resourceHandler.getString("testview.password"));
    How to solve this error?
    Guide me.
    Advance Thanks,
    Balaji

    Hi Friends,
    I had developed one web dynpro application by using Internationalization - I18N of WebDynPro -Java Application (Blog) but I got one error that is
    <b>java.util.MissingResourceException: Can't find bundle for base name com.sap.example.language.lang, locale en_US</b>
    Actually i created two properties file
    1. lang_en.properties
    2. lang_ta.properties
    I stored this two properties file in this package com.sap.example.language
    and this my code in DOInit()
    sessionLocale = WDClientUser.getCurrentUser().getLocale();
    resourceHandler = ResourceBundle.getBundle("com.sap.example.language.lang",sessionLocale);
    catch (WDUMException e)
    e.printStackTrace();
    wdContext.currentContextElement().setUsername_label(resourceHandler.getString("testview.username"));
    wdContext.currentContextElement().setPassword_label(resourceHandler.getString("testview.password"));
    How to solve this error?
    Guide me.
    Advance Thanks,
    Balaji

  • How to solve the error 'please enter account assignment ' in BAPI_PO_CREATE.

    Hi gurus,
    While creating shopping cart with an  item from services type  i am getting error please enter account assignment.Please suggest me how to solve this error
    thanks&regards,
    Suneel Kumar.

    Hi Suneel,
    Are you getting while transferring the Shopping cart into ECC? Or you are getting while creating Shopping cart in SRM?
    Thank you
    Ritesh

  • How to solve the error 0xBFF6902B in Ni-Max??

    Hello,
    I am trying to communicate with Axis camera with Ni-vision , but I am getting the error as I mentioned.
    Here in attachment I have attached the screenshot of error.
    Would you please guide me how to solve this error.
    Thank you very much.
    Attachments:
    error.png ‏982 KB

    Hello,
    I have a camera in My robot its Axis camera and its working fine in when I connect my robot and handle with labview.
    But I am not able to detect that camera in Ni-Max as I want to develop some functionality of robot camera in Ni-IMQ.
    When I tried to connect then I Got the error Error - 1074360277 occurred at IMAQdx Open Camera.vi,
    would you please help me how to solve this problem.
    Ip address of camera also responding well.
    Please guide me what should be the possible way to solve this problem I am using labview 2012.
    Attachments:
    erro.png ‏231 KB

  • How to solve the error "The specified resource is reserved" when running with DAQmx And LabVIEW?

    How to solve the error "The specified resource is reserved" when running with DAQmx And LabVIEW?

    I hate "J term"
    OK I love the learning the students get.   And, I like helping them out!  But, as a former man who's got the varicose viens to prove he's spent time "behind the podium" (yeah, "behind the podium" puts 'em to sleep- songs and dances for the young'uns) come on! USE the tools you teach!
    Instructors invited to engage in the forums
    Jeff

  • How to solve the error no sid found?

    how to solve the error no sid found?

    Hi,
    The system will give you the error like this.. No SID found for value '0000030016 ' of characteristic "CUSTOMER"
    Go to Customer infosource give the selection "'0000030016" and load the master data. And then update the transaction data from PSa if not reload it.
    Assign points if helps
    Regards
    srini

  • How to solve the error sid missing?

    how to solve the error sid missing?

    Hi,
    Loading data sometimes you get SID error inconsistencies on master data, do a combined test by using TCODE RSRV on the infoobject, fix then problem and reload data.
    Hope it useful.
    Thanks,
    Somesh.

  • How to solve this error using OSX Server's bots

    Plz help me.
    My remote repository is SVN version controll system.
    when I started integration using bot in OSX Server. this error was pisplayed on a log.
    how to solve this error to integrate my project using OSX Server.
    Apr  3 16:56:42 server.mbkwon.com xcsbuildd[20259] <Debug>: [XCSBuildBundle.m:466 77537310 +61ms] Will NOT send email notifications because notifyCommitterOnFailure is NO Apr  3 16:56:42 server.mbkwon.com xcsbuildd[20259] <Debug>: [XCSBuildBundle.m:470 77537310 +0ms] Posting email notification for bot run with type com.apple.notifications.BotFailed Apr  3 16:56:42 server.mbkwon.com xcsbuildd[20259] <Debug>: [XCSBuildBundle.m:471 77537310 +0ms] Sending email to committers = (null) Apr  3 16:56:42 server.mbkwon.com xcsbuildd[20259] <Debug>: [XCSBuildBundle.m:1033 77537310 +0ms] Posting notification of type com.apple.notifications.BotFailed Apr  3 16:56:42 server.mbkwon.com xcsbuildd[20259] <Debug>: [XCSBuildHelper.m:199 77537310 +0ms] Posting notification for bot run GUID f87f0098-f8ca-4bfa-945e-cbb11a2f6abb of type com.apple.notifications.BotFailed Apr  3 16:56:42 server.mbkwon.com xcsbuildd[20259] <Info>: [CSRemoteServiceClient.m:151 77537310 +0ms] Connecting to https://localhost:4443/svc to execute [https]Request{AuthService.enterMagicalAuthRealm()} Apr  3 16:56:42 server.mbkwon.com xcsbuildd[20259] <Info>: [CSRemoteServiceClient.m:151 77537310 +45ms] Connecting to https://localhost:4443/svc to execute [https]Request{XCBotService.postNotificationForBotGUID:andRunGUID:andNotificati onType:additionalEmails:(c6189ca0-0649-0649-c01e-81c4d0b52dd9,f87f0098-f8ca-4bfa -945e-cbb11a2f6abb,com.apple.notifications.BotFailed,( ))} Apr  3 16:56:42 server.mbkwon.com xcsbuildd[20259] <Debug>: [XCSBuildBundle.m:601 77537310 +84ms] Deleting work queue item: cf7fe6b8-4df8-b723-4794-50fbf27955ed Apr  3 16:56:42 server.mbkwon.com xcsbuildd[20259] <Info>: [CSRemoteServiceClient.m:151 77537310 +0ms] Connecting to https://localhost:4443/svc to execute [https]Request{XCWorkQueueService.deleteWorkQueueItemWithGUID:(cf7fe6b8-4df8-b7 23-4794-50fbf27955ed)} Apr  3 16:56:42 server.mbkwon.com xcsbuildd[20259] <Debug>: [XCSBuildBundle.m:929 77537310 +13ms] Marking build bundle complete with status failed and sub-status internal-checkout-error Apr  3 16:56:42 server.mbkwon.com xcsbuildd[20259] <Info>: [CSRemoteServiceClient.m:151 77537310 +0ms] Connecting to https://localhost:4443/svc to execute [https]Request{AuthService.enterMagicalAuthRealm()} Apr  3 16:56:42 server.mbkwon.com xcsbuildd[20259] <Debug>: [XCSBuildHelper.m:97 77537310 +55ms] Updating bot run with GUID f87f0098-f8ca-4bfa-945e-cbb11a2f6abb Apr  3 16:56:42 server.mbkwon.com xcsbuildd[20259] <Debug>: [XCSBuildHelper.m:102 77537310 +0ms] Updating bot run (f87f0098-f8ca-4bfa-945e-cbb11a2f6abb): { guid = "f87f0098-f8ca-4bfa-945e-cbb11a2f6abb"; status = failed; subStatus = "internal-checkout-error"; } Apr  3 16:56:42 server.mbkwon.com xcsbuildd[20259] <Info>: [CSRemoteServiceClient.m:151 77537310 +0ms] Connecting to https://localhost:4443/svc to execute [https]Request{XCBotService.updateBotRun:({ guid = "f87f0098-f8ca-4bfa-945e-cbb11a2f6abb"; status = failed; subStatus = "internal-checkout-error"; })} Apr  3 16:56:42 server.mbkwon.com xcsbuildd[20259] <Debug>: [XCSBuildHelper.m:108 77537310 +121ms] Updating bot with GUID c6189ca0-0649-0649-c01e-81c4d0b52dd9 Apr  3 16:56:42 server.mbkwon.com xcsbuildd[20259] <Debug>: [XCSBuildHelper.m:117 77537310 +0ms] Updating bot with latest bot run GUID key Apr  3 16:56:42 server.mbkwon.com xcsbuildd[20259] <Debug>: [XCSBuildHelper.m:124 77537310 +0ms] Updating bot (c6189ca0-0649-0649-c01e-81c4d0b52dd9): { guid = "c6189ca0-0649-0649-c01e-81c4d0b52dd9"; latestFailedBotRunGUID = "f87f0098-f8ca-4bfa-945e-cbb11a2f6abb"; latestRunStatus = failed; latestRunSubStatus = "internal-checkout-error"; } Apr  3 16:56:42 server.mbkwon.com xcsbuildd[20259] <Info>: [CSRemoteServiceClient.m:151 77537310 +0ms] Connecting to https://localhost:4443/svc to execute [https]Request{XCBotService.updateBot:({ guid = "c6189ca0-0649-0649-c01e-81c4d0b52dd9"; latestFailedBotRunGUID = "f87f0098-f8ca-4bfa-945e-cbb11a2f6abb"; latestRunStatus = failed; latestRunSubStatus = "internal-checkout-error"; })}

    Hello,
    You need to make sure both names match exactly

  • Ajax submit failed: error = 403, forbidden----how can solve this error

    Ajax submit failed: error = 403, Forbidden--how can solve this error to create a new eprintcenter account

    I am having the SAME problem.  This is so frustrating.   If i try to log on with teh user account I already have, I get the above message.  If i try to create a new accoutn it says the account is already existing.  If i click on forgot password, nnothing happens.  HELP!  I am stuck in a loop!!

  • TS3694 How to solve the error 1015?

    How to solve the error 1015?

    Use google.  You have a hacked or jailbroken phone, you can't get any help here, it's the against the forum term of use.

  • How to solve this error from window phone 80073cf9 lumia 630.

    any one know how to solve this error from window phone 80073cf9  lumia 630.

    Hello Muhammad,
    We appreciate the post, but this forum is for Windows Store and Phone Developer related questions. Your question can best be answered through the
    Windows Phone support page.
    Thanks!
    -Jonathan
    Windows Store Developer Support
    Office Store Developer Support

Maybe you are looking for

  • Problem with rebuilding iPhoto library

    Hi, I'm having problem to rebuild my iPhoto library. I have more than 11 000 photos / video clips and 70Gbs in my iPhoto library and everything has been ok until I started to import photos from my new iPhone 4. First issue was that when I imported ph

  • Is it possible to create a variable that tells you which slides the user has visited?

    Hi there. I'm working on a project where I want a slide to show a continue button and hide 2 textboxes, but ONLY when the user has already visited 2 other slides. I can only find variables that tell you the slide the user previously visited. Is it po

  • ODS Modelling

    The client wants to implement SAP BW with Cognos on Top. They say they want ODS’s (because of high detail of data).and unfortunately Cognos does not allow ODS reporting, so we have to rely on Infosets. Infosets allows direct joins between info object

  • Hyperlink Formula Correction

    Hi, I use BOXI r2 sp4. I have a crosstab report with 3 tabs.  There is a prompt on the Billing Year Month dimension which is based on "between". I would like to hyperlink from the Summary Tab to the Detail for One Server Tab. I'm receiving an error m

  • Please anyone answer this !!!!!!

    One of our user created an ACH file and sent it to the bank for payment.He created this ACH file in one bank but by mistake sent it to other bank for payment.The payment has been cleared . Because of this my bank balances have changed. Could anyone h