0

I'm a bit new to Java. How do I compile a private utility method, checkSize(String[] data) that checks incoming data for every conceivable size or null error (Smaller data is okay. Bigger data or null is not ok). It should be in the form of a boolean.

Here is the pseudocode.

  // Initially set all data objects to null here?
  try 
  {
     if (data != null && data.length > 0)
     { 
        System.out.println(data.length);  
     }                   
  } 
  catch (Exception e) 
  {
      System.out.println(e.getMessage());     
  }
  return true; 

}

Masha
  • 1
  • 1
  • write down what you try t do in pseudo code, then implement it in code – Stultuske Sep 24 '16 at 08:12
  • Could you provide a usage example? How do you plan to call this utility method? – default locale Sep 24 '16 at 08:13
  • This method is for a barcode scanner java program. Basically, it will check if the data in the String[] is not null or too large, then return only valid data and error for invalid data. – Masha Sep 24 '16 at 08:16
  • What do you mean by "too large" ? is there any specific size of *data* that you want to check ? If so what is that ? – Rahman Sep 24 '16 at 08:24
  • Basically, I have a String[] data (Java array) that draws a 2D bar code with symbols of * and white spaces. The exact internal dimensions of 2D data is set to: my assumption is that we are checking that the data does not go pass the max_height and max_width of itself. public static final int MAX_HEIGHT = 30; // X coordinate public static final int MAX_WIDTH = 65; // Y coordinate – Masha Sep 24 '16 at 08:37
  • in my data string array, the black surfaces are represented by * and the white surfaces are represented by " " empty space string. See picture of bar code. https://www.google.com/search?q=bar+code+2d+drawing+java&rlz=1C5CHFA_enUS695US695&espv=2&biw=1440&bih=826&source=lnms&tbm=isch&sa=X&ved=0ahUKEwiT_YnKzafPAhXBEywKHZg_BBUQ_AUIBigB#imgrc=Ye86xjcnD2ViaM%3A – Masha Sep 24 '16 at 08:41

0 Answers0