Results 1 to 4 of 4
  1. #1
    vknehra10 is offline Senior Member
    Join Date
    Dec 2016
    Posts
    103
    Rep Power
    0

    Default Array Is not subtracting

    Java Code:
     ResultSet dt=dep_time.executeQuery();
                ArrayList<String> dp_dt=new ArrayList<String>();
                while(dt.next()){
                    
                    dp_dt.add(dt.getString("dep_time"));
                }
                ResultSet at=arr_time.executeQuery();
                ArrayList<String> al_dt=new ArrayList<String>();
                while(at.next()){
                    al_dt.add(at.getString("arr_time"));
                    
                }
                
                
                
                
                int d=0;
                int a=0;
                
                String time=null;
                
                    String tm[]=dp_dt.toArray(new String[dp_dt.size()]);
                    String tm1[]=al_dt.toArray(new String[al_dt.size()]);
                    
                    String tm2[]=new String[tm.length];
                      
                              for(int j=0;j<tm.length;j++){
                                  tm2[j]=tm[j]-tm1[j];         //Its showing a bad operand error..
                              }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    25

    Default Re: Array Is not subtracting

    You are trying to subtract two Strings.
    You can't do that.

    You might need to explain what it is you are trying to do, and what values those Strings contain.
    I think I can guess, but it would be best for you to explain it.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    vknehra10 is offline Senior Member
    Join Date
    Dec 2016
    Posts
    103
    Rep Power
    0

    Default Re: Array Is not subtracting

    I am fetching two diferent train time from a table and store into two array list
    After that i want to find time taken
    So i store into a array and then try to subtract to find time taken...

    Thanks

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,960
    Rep Power
    31

    Default Re: Array Is not subtracting

    Can the Strings be parsed to date or calendar objects that have methods to do computations?
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Adding/Subtracting a int
    By Alkor in forum New To Java
    Replies: 10
    Last Post: 03-09-2012, 08:32 AM
  2. getting a date value from db and subtracting it in jsp
    By dayalan in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 03-14-2011, 10:05 AM
  3. Subtracting 2d Arrays
    By Spyderpig in forum New To Java
    Replies: 9
    Last Post: 03-11-2011, 06:12 AM
  4. Subtracting Strings
    By ravian in forum New To Java
    Replies: 7
    Last Post: 10-08-2009, 07:26 PM
  5. Subtracting Strings
    By lazygun247 in forum New To Java
    Replies: 6
    Last Post: 03-29-2009, 11:05 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •