• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Comparing array elements between 2 different arrays

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok.... I am trying to compare elements of 2 arrays and have had no success. This is what i am trying to do... get a list of a folder and store it in an file[] array. Then i get the lenght() of that file and want to store it in an long[], since that is what the .lenght() returns (from java.io.File). However, when I run this example i get the following error.. that error refers to this line.. sizeWorkFolder[i] = filesInWorkFolder[i].length(); //stores size of file to array
The intresting thin is that if i replace sizeWorkFolder[i] for a regular long variable, i get no error!!

Exception in thread "main" java.lang.NullPointerException
at DownloadFolderSample.main(DownloadFolderSample.java:71)



 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Eduardo Ponce de Leon wrote:


I'm assuming that the sizeTempFolder = 0 is a left-over from your experiments with replace it by a long. Try initializing the arrays.
 
Whose rules are you playing by? This tiny ad doesn't respect those rules:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic