easier way to format lines of code in Java to make your job easier? -


i making application uses api , prints out information thing. gets api , if system.out.println(result.getplayer().get("displayname")); return display name of player searching for. wondering if there way make result.getplayer().get("displayname") variable because have hundreds of statistics need gather. possible have line of code called displayname? sorry if don't understand.

i suggest make special statistics/logging class has static methods this. example case, following class can used both name , print it. of course can combine them single method if want 1 functionality.

public class statslog {     public static string getplayerdisplayname(final result result) {         return (result == null)             ? null             : result.getplayer().get("displayname");     }      public static void printplayerdisplayname(final result result) {         final string displayname = getplayerdisplayname(result);         if (displayname != null) {             system.out.println(displayname);         }     } } 

and when call it:

statslog.printplayerdisplayname(result); 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -