Java expression - hot express ArrayIndexOutOfBounds in If Statement

Hi !
I would like to know how I can express the following correctly:
Testcode - just to show what i mean:
int[][] testArray = whatever assignments here
if (testArray[line][row] != ArrayIndexOutOfBoundsException)
.... do stuff here...
}As obvious I basically just wanna add numbers across this twodimentional array - in rows - not lines !.
And as some lines and rows can be shorter than others, eventually Ill end up with an OutOfBoundsException.
So how can I handle those inside the if statement ? What is the correct expression to avoid those?
As the current expression doesent work.
As obviously those slots are NOT null but literally non existent slots, that must be checked for before adding the int inside.
Thanks for help !

"sort on the array" ?
yeah actually where can I look up the methods for arrays ?
anyway, I left it a bit and eventually came back to it:
Now I have it fixed to calculate the columns for any 2D array
Cheers for the good comments though !
zeile = line
spalte = column
    int spaltenMax = 0;
    for (int zeile = 0; zeile < data.length; zeile++)
         if (spaltenMax < data[zeile].length)
              spaltenMax = data[zeile].length;              
    System.out.println("There are " + spaltenMax +" columns" );
    for (int spalte = 0; spalte < spaltenMax; spalte++)
        for (int zeile = 0; zeile < data.length; zeile++)
                  int zeilenL = data[zeile].length;
                  if (zeilenL-1 >= spalte)
                       rowSum += data[zeile][spalte];
        System.out.println("For column " +(spalte+1)  + " the sum is: " +rowSum );
        rowSum = 0;       
   

Similar Messages

  • SQL Expression in decode function or case statement?

    Can I put SQL expressions in decode function or case statement?
    For example,
    select le.profile, decode( select count(1) from profile_data where NAME= 'XXXX_AFTER' and object_id = le.profile, 0, 'N', 'Y')
    from element le;
    or
    select le.profile, case WHEN ( select count(1) from profile_data where NAME= 'XXXX_AFTER' and object_id = le.profile) = 0 THEN 'N'
    ELSE 'Y'
    from element le;
    None of the above work.
    Can anyone tell me how to make it work?
    Is there any workaround?
    Thanks,
    J

    You simply needed and END to your CASE statement;
    SQL> with profile_data as (
       select 'XXXX_AFTER' name, 1 object_id from dual),
         element as (
       select 1 profile from dual union all
       select 2 from dual)
    select le.profile,
       case WHEN ( select count(1) from profile_data where NAME= 'XXXX_AFTER' and object_id = le.profile) = 0
       THEN 'N'
       ELSE 'Y'
       END new_col
    from element le
       PROFILE N
             1 Y
             2 N

  • Java System Communications Express attachment problem

    Hello everyone, please excuse my ignorance on this query as I have very little to do with the Java language and I've really approached this forum as I've run out of ideas for the problem my customer has.
    The customer is connecting to a 'Sun Java System Communications Express' server, from approximately 20 PC's. 2 of the PC's have a problem that is not user based because if they sign in elsewhere their problem disappears and likewise if someone signs into their PC, they experience the same problem.
    If the user receives an email with an attachment and forwards it to a recipient, no problem.
    If the user recieves an emal with an attachment and forwards it to themselves, no problem.
    If however, the user tries to send an email with an attachment (which for all intents and purposes seems to take the correct amount of time to upload, and when you click save appears in the message attached) the attachment disappears, including if you simply save the message in drafts and do not actually send it.
    I have tried uninstalling and reinstalling versions 5 and 6 of Java, resetting the web settings using both IE6 and IE7 (unfortunately the initial secure server refuses any other connections from Firefox / Netscape / Opera / Safari therefore I can only test with IE)
    I have disabled all additional addons, disabled all non-microsoft startup services, disabled all startup programs.
    As you will appreciate, I've done a fair and reasonable amount of testing and simply cannot work out why the attachment fails to stay with the email on these two machines. Help on this problem would be very much greatly appreciated.
    Many Thanks
    Tony

    Unfortunately I do not have access to version information of the server as I am only have access to the client end. All that I can provide you with is the fact that it works on 18 identical systems. The missing attachment(s) occur regardless of whether you save the message to draft or send the message. It should be noted however that if you receive an attachment with a message and save that to drafts, the message retains the attachment so it only seems as though it is affected during the phase of attaching the file to the message from the local PC. The environment that the client is working in uses a verified certificate and is connected through https.

  • Validate form entries: does java support regular expressions?

    i want to validate form entries, does java support regular express like javascript?

    Just recently in 1.4 regex was finally introduced :)
    Take a look at http://developer.java.sun.com/developer/technicalArticles/releases/1.4regex/

  • Help with Java and Regular Expression

    Hello,
    I have one line of Java and regular expression that I got from the web :
    String[] opt;
    opt = line.split("\\s+(?=([^\"]*\"[^\"]*\")*[^\"]*$)");
    If "line" contains :
    1 "Hello World"
    this code would give me :
    opt[0] : 1
    opt[1] : "Hello World"
    which is almost what I would like to do except for the double quotes. I wonder if someone could please help me change the regular expression so that it would return :
    opt[0] : 1
    opt[1] : Hello World
    Thank you and Best Regards,
    Chris

    It looks to me like this is a line from a space delimited file so you should use one of the free CSV parsers such as http://opencsv.sourceforge.net/ . These will handle the quotes properly even if a field actually contains a quote.

  • Sun Java System Communications Express 6

    Does anyone have information about Sun Java System Communications Express?
    Has it been released? What are your opinions, etc?
    Thanks,
    GB

    i started with schema 2
    so installed directory identity - verified them
    ran instalelr again and instaleld messagign , calendar - tested them
    then installed communicatiosn express and configured as per setup docs - configured them for identity sso not messaging sso
    l8r

  • Blank Page with sun Java System Calendar Express and IE6

    Hi Everybody,
    I saw a few threads related to my problem, but no solutions ....
    When I try to open the Sun Java System Calendar Express web-interface with IE6, I get a blank page after the initial logon-screen. IE7 and Firefox do not show this problem - so I assume the server itself is working fine.
    I run SJS-CS v6.3 with patch 121659-18 on Linux.
    Otherwise the calendar server is working just fine - problem is, that I cannot switch all users to new/other browsers ...
    Any ideas ?
    Cheers, Stefan!

    stefvienna wrote:
    I saw a few threads related to my problem, but no solutions ....
    When I try to open the Sun Java System Calendar Express web-interface with IE6, I get a blank page after the initial logon-screen. IE7 and Firefox do not show this problem - so I assume the server itself is working fine.What have you got set for the following ics.conf attributes?
    render.xslonclient.enable
    ui.toolbar.repainting.enable
    I run SJS-CS v6.3 with patch 121659-18 on Linux.Let me just point out that calendar express is deprecated with CS6.3 (no more features/enhancements) so you should be looking to move to UWC/CE.
    Otherwise the calendar server is working just fine - problem is, that I cannot switch all users to new/other browsers ...Did this problem start when you upgraded to 6.3 or is this a new installation?
    Regards,
    Shane.

  • Java.sql.SQLException: Unexpected token: IN in statement

    I use Toplink 2.0-b41-beta2 (03/30/2007) and have a problem with the following JPQL query:
    “SELECT DISTINCT OBJECT(e) FROM Entry e WHERE e.location IN (SELECT loc From View v JOIN v.viewLocs vl JOIN vl.location loc where v.code = :code)”
    “Entry” is a subclass of “TrainElement”, location points to Entity Location. Entity View has a one-to-many relationship to ViewLoc whereas each ViewLoc has a relationship to a Location object.
    Toplink creates the following incorrect sql statement – I inserted some CRLF for better readability::
    Local Exception Stack:
    Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: Unexpected token: IN in statement
    [SELECT DISTINCT t0.TELEM_TRAINELEM_ID, t0.TRAINELEMENT_TYPE, t0.TELEM_INDEX, t0.TTELEM_TRAIN_ID, t0.ENTRY_TYPE, t0.ENTRY_ARRIVAL, t0.DISPLAY, t0.ENTRY_ORDERED_STOP, t0.ENTRY_DEPARTURE, t0.ENTRY_ORDER_CODE, t0.ENTRY_PREV_SEC_ID, t0.ENTRY_NEXT_SEC_ID, t0.ENT_LOC_ID FROM TRAINELEMENT t0, LOCATION t1
    WHERE (( IN ((SELECT DISTINCT t2.LOC_ID, t2.LOC_GPSY, t2.LOC_GRX, t2.LOC_CODE, t2.LOC_GRY, t2.LOC_GPSX, t2.LOC_LOCAL_RADIO, t2.LOC_NAME, t2.DELETED, t2.LOC_CLASS_ID FROM VIEW t4, VIEWLOC t3, LOCATION t2 WHERE ((t4.VIEW_CODE = ?) AND ((t3.VIEWLOC_VIEW_ID = t4.VIEW_ID) AND (t2.LOC_ID = t3.VIEWLOC_LOCACTION_ID))))) AND (t0.TRAINELEMENT_TYPE = ?)) AND (t1.LOC_ID = t0.ENT_LOC_ID))]
    Error Code: -11
    Call: SELECT DISTINCT t0.TELEM_TRAINELEM_ID, t0.TRAINELEMENT_TYPE, t0.TELEM_INDEX, t0.TTELEM_TRAIN_ID, t0.ENTRY_TYPE, t0.ENTRY_ARRIVAL, t0.DISPLAY, t0.ENTRY_ORDERED_STOP, t0.ENTRY_DEPARTURE, t0.ENTRY_ORDER_CODE, t0.ENTRY_PREV_SEC_ID, t0.ENTRY_NEXT_SEC_ID, t0.ENT_LOC_ID FROM TRAINELEMENT t0, LOCATION t1 WHERE (( IN ((SELECT DISTINCT t2.LOC_ID, t2.LOC_GPSY, t2.LOC_GRX, t2.LOC_CODE, t2.LOC_GRY, t2.LOC_GPSX, t2.LOC_LOCAL_RADIO, t2.LOC_NAME, t2.DELETED, t2.LOC_CLASS_ID FROM VIEW t4, VIEWLOC t3, LOCATION t2 WHERE ((t4.VIEW_CODE = ?) AND ((t3.VIEWLOC_VIEW_ID = t4.VIEW_ID) AND (t2.LOC_ID = t3.VIEWLOC_LOCACTION_ID))))) AND (t0.TRAINELEMENT_TYPE = ?)) AND (t1.LOC_ID = t0.ENT_LOC_ID))
         bind => [ROMAN W-Pb, ENT]
    There sould be a “t0.ENT_LOC_ID” before the IN in the WHERE clause and the implicit join “ID FROM TRAINELEMENT t0, LOCATION t1” seems incorrect to me. At any rate the database (HSQLDB) rejects that incorrect sql statement.
    How can I circumvent that problem?
    A add the relevant mapping part of the involved classes.
    @Entity
    @DiscriminatorValue("ENT")
    public class Entry extends TrainElement implements IEntry {
         @ManyToOne(cascade = CascadeType.ALL)
         @JoinColumn(name = "ENT_LOC_ID", nullable = true)
         private Location location;
    @Entity
    @Table(name = "LOCATION")
    public class Location implements ILocation {
         // persistent part
         // primary key field
         @Id
         @GeneratedValue
         @Column(name = "LOC_ID")
         private Long id;
         @Column(name = "LOC_CODE", nullable = false)
         private String code;
         @Column(name = "LOC_NAME", nullable = false)
         private String name;
    @Entity
    @EntityListeners(EntityListener.class)
    @Table(name = "VIEW")
    public class View implements IView {
         // persistent
         // primary key field
         @Id
         @GeneratedValue
         @Column(name = "VIEW_ID")
         private Long id;
         @OneToMany(mappedBy = "view", cascade = CascadeType.ALL)
         private List<ViewLoc> viewLocs = new ArrayList<ViewLoc>();
    @Entity
    @Table(name = "VIEWLOC")
    @EntityListeners(EntityListener.class)
    public class ViewLoc implements IViewLoc {
         // persistent fields
         // primary key field
         @Id
         @GeneratedValue
         @Column(name = "VIEWLOC_ID")
         private Long id;
         @ManyToOne(cascade = CascadeType.ALL)
         @JoinColumn(name = "VIEWLOC_VIEW_ID", nullable = false)
         private View view;
         // direct Linking to the infrastrucutre location
         @ManyToOne(cascade = CascadeType.ALL)
         @JoinColumn(name = "VIEWLOC_LOCACTION_ID")
         private Location location;
    ….

    IN doesn't support objects, only state_field_path_expression that must have a string, numeric, or enum value.
    Try using
    “SELECT DISTINCT OBJECT(e) FROM Entry e WHERE e.location.id IN (SELECT loc.id From View v JOIN v.viewLocs vl JOIN vl.location loc where v.code = :code)”
    Best Regards,
    Chris

  • Transport BRF expressions of expression type SAP Formula Interpreter

    Hi Experts,
    How can i copy BRF expressions of expression type SAP Formula Interpreter to one request for transport to another client?
    When we copy using tcode FKKBRFTRANS, the formula appear empty on the new client.
    Best regards,
    Renato Tasso

    Hi Renato,
    So I'm guessing that's really BRF then and not BRF+ ? Most of the forum participants in this space are BRF+ or BRM users, and most of us keep very clear of BRF itself...
    You might need to search on that Tcode and see if there's a functional forum that's aware of it or else report it via SAP Message.
    Rgds,
    Jocelyn

  • I tried to open my Illustrator CS6 today and got the following error message, "To open Adobe Illustrator CS6 you need to install the legacy Java SE runtime". The window then states, "Click More info...to visit the legacy Java SE 6 download website."  I do

    Help. I tried to open my Illustrator CS6 today and got the following error message, "To open Adobe Illustrator CS6 you need to install the legacy Java SE runtime". The window then states, "Click More info...to visit the legacy Java SE 6 download website."  I do click on the More Info... button, but the webpage is blank. Please help.
    Thanks,
    Leo

    Leo,
    Depending on your OS, you should be able to use;
    Win:
    http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419 409.html
    Mac:
    http://support.apple.com/kb/DL1572
    Some have found that the page may turn up blank to start with, so it may be necessary to reload the page.
    Others have found that it may depend on browser. Specifically, a switch from Safari has solved it in one case.

  • Where can i download personal express and express analyzer?

    Hi all,
    I tried to find oracle personal express and express analyzer on oracle software downloading page, but with no lucky. Do you know where i can download these two softwares?
    thanks
    XG

    These products are still available on Metalink as part of a patchset
    2378248 Express Server Client Kit 6.3..4
    Regards,
    Frank

  • Where in the chomsky hierachy are java/perl regular expressions?

    hi,
    does anyone know (or of any links that talk about) where java/perl (they are the same?) regular expressions fit in the chomsky hierachy (and which operators take them out of the regular languages?)?
    thanks,
    asjf

    does anyone know (or of any links that talk about)
    where java/perl (they are the same?) regular
    expressions fit in the chomsky hierachy (and which
    operators take them out of the regular languages?)?From a mathmatical viewpoint, regular languages can always be described by regular expressions. I've always assumed java/perl were the same. I looked at the all the possible patterns listed(http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html#sum) and I know I easily could create a finite state machine for any of expressions listed except in the last section. This would prove they are regular languages. The reason I can't do the last section is because I don't understand what they mean. I don't know understand what they mean by things like 'X, via zero-width positive lookahead' and a quick google search didn't give me any good examples/clarifications.

  • Send email attachments using Java through Outlook Express

    Hi
    Can anyone suggest how we can interface Outlook Express with java in
    order to send email?
    I want to add 'Email Friend' link in my project, on clicking on this
    link Outlook Express should open with a specified file attached.
    I searched on net also, but I am getting only JOC everywhere which is
    not freeware.
    Please suggest me on the same that how it can be done?
    Thanks
    Ashi

    You can send files to Outlook Express using following:
    using a windows exe runmenu. exe
           File file = new File("./lib/runmenu.exe");
            try
                String commandForNotesMail =
                    file.getCanonicalPath() +
                    " \"/exec: send to\\mail recipient\" " + filename;
                System.out.println("Cononical Path :" + commandForNotesMail);
                Runtime.getRuntime()
                    .exec(commandForNotesMail);
            catch (IOException e)
                e.printStackTrace();
            return true;
        }

  • Java on oracle express 11g  xe- Can it be used for College Database Website

    I am a fairly new IT student, I took C programming and I am trying to learn JAVA. I got a job opportunity to work doing some programming using JAVA on an Oracle database, to do part of a school webite, including creating tests online for students that attend the college. However, I have to create a sample to demonstrate knowledge of Oracle and Java, and was allowed two weeks to figure it out.
    Can I use Oracle Jdeveloper for the java portion with the Oracle Express 11g xe to create a sample?
    THE SAMPLE INCLUDES: Creating a part of an online test for a student that asks 5 questions, where the student fills out the answers along with name and student id number, and also for the test to be scored passed or failed. Also, the test has to store the answers in a place where another user/teacher can have access to the students test answers. Would this work on Oracle Express 11g xe using jdeveloper?
    I really dont have any experience or taken any classes on databases.

    >
    Can I use Oracle Jdeveloper for the java portion with the Oracle Express 11g xe to create a sample?
    >
    I don't see why not. See the Oracle Express Home Page
    http://www.oracle.com/technetwork/products/express-edition/overview/index.html
    >
    Oracle Database 11g Express Edition (Oracle Database XE) is an entry-level, small-footprint database based on the Oracle Database 11g Release 2 code base. It's free to develop, deploy, and distribute; fast to download; and simple to administer.
    Oracle Database XE is a great starter database for:
    Developers working on PHP, Java, .NET, XML, and Open Source applications
    DBAs who need a free, starter database for training and deployment
    Independent Software Vendors (ISVs) and hardware vendors who want a starter database to distribute free of charge
    Educational institutions and students who need a free database for their curriculum
    With Oracle Database XE, you can now develop and deploy applications with a powerful, proven, industry-leading infrastructure, and then upgrade when necessary without costly and complex migrations.
    Oracle Database XE can be installed on any size host machine with any number of CPUs (one database per machine), but XE will store up to 11GB of user data, use up to 1GB of memory, and use one CPU on the host machine.
    Support is provided through a free Oracle Discussion Forum monitored by Oracle employees as well as community experts.

  • Java equivalent with expression?

    noob here.
    is there a java equivalent of the vb with expression?
    with someObect
    .propery = someValue
    .method
    End with

    Don't know VB, but at 1st appearance it kind of looks like:
    someObject.property = someValue;
    someObject.method();

Maybe you are looking for

  • Proforma Invoice in Intracompany  STO Process

    Hi Gurus, I am trying to make Proforma Invoice in STO Intra company. But it is giving the errror "Not relevant for billing". Actually i want to create a excise Invoice from this Pro forma Invoice. I have also maintained NLN item category in Copy cont

  • MSS Iview error - Any  body  help me - Very urgent

    Hello All, I've configured ESS BP in my Portal successfully and it's running perfectly fine. Now i've imported MSS also without any problems. Now the issue is when i'm launching the My Staff iViews it gives me a message "Could not connect to the R/3

  • Help getting my xbox 360 to see my shared external drive

    I have an Xbox 360 that is hard wired to my Airport Extreme. I also have an external hard drive hard wired sharing on my network. I am trying to get the Xbox to see the shared drive so that I can view my content. I searched all over the internet tryi

  • Photo stream will not work in Aperture

    I have photo stream and sharing set up on iCloud and when signed in Aperture keeps asking me to sign in when I check the box to set up Photos stream. There is an obvious logic error as the message to sign in on iCloud will not go away even though I a

  • Webutil   and jacob software

    while trying to run the jacob.jar we are running into into the following error 'Failed to load mail-class manifest attribute from c:\webutil\lib\jacob.jar' How can this error be trouble shooted, what should we check and verify?