good SAP References

Steven has started to document his daily works with SAP development in his blog.
www.sorj.de

you may find lots of valuable insides and hints about ABAP development there.
Furthermore, he has also written tutorials about Scala. So just go and check it out.

Advertisements

optional parameters in java method

More about optional parameters in java can be found in
http://stackoverflow.com/questions/965690/java-optional-parameters
Sometimes these optional parameters in method call can be very useful,
here is an example of this, which uses java varargs feature. More about varargs can be found unter the link:
https://docs.oracle.com/javase/tutorial/java/javaOO/arguments.html (section: Arbitrary Number of Argument)

public class Main {
 /*
  * Running the ParamTest you will get
  * Listing: 1;2;3;
  * Listing: 1;2;
  * Listing: 0;2;
  * Listing: 0;
  * Listing:
  */
 public static void main(String[] args) {
  // run paramTest case 01
  paramTest01(args); 
 }
 private static void paramTest01(String[] args) {
   String[] numStrings = {"1","2","3"}; 
   char seperator = ';'; 
   pl(foo(seperator, numStrings));
   pl(foo(seperator,"1","2"));
   pl(foo(seperator,null,"2"));
   // if giving the optional param "null" instead of (String)null, 
   // you will get an NullPointerException 
   pl(foo(seperator,(String)null));
   pl(foo(seperator)); }

 /* optional params with the same data type string 
  * (Use Object ... objects for optional params with different data types)
  */  
 private static String foo(char seperator, String ... strings) {
   StringBuffer buffer = new StringBuffer();
   buffer.append("Listing: ");
   for (int i = 0; i < strings.length; i++) {
     // elimination of null 
     strings[i] = (strings[i] != null ? strings[i]:"0");
     buffer.append(strings[i]);
     buffer.append(seperator);
   } 
   return buffer.toString(); 
 } 

 private static void pl(String in) {
   System.out.println(in); }
}