metaperl.etc@gmail.com wrote:
Ok, I just want to know if you have any suggestions for improving this
code. I dont like typing System.out before all my I/O calls but I
cant extend System.out because I am extending DepthFirstAdapter.
I dont like calling print() one line and then println() on the next.
Something like printf would be nice.
Any other suggestions welcome.
System.out.print("arg1 ");
System.out.println(node.getArg1());
System.out.print("arg2 ");
System.out.println(node.getArg2());
System.out.print("dyad ");
System.out.println(node.getDyad());
Double arg1 = Double.parseDouble(node.getArg1().toString());
Double arg2 = Double.parseDouble(node.getArg2().toString());
Double sum = arg1 + arg2 ;
System.out.print("Their sum: ");
System.out.println(sum);
Why not use the + operator for strings/objects ?
(and BTW: the Double-handling can be shortened a bit, too)
System.out.println("arg1 " + node.getArg1());
System.out.println("arg2 " + node.getArg2());
System.out.println("dyad " + node.getDyad());
double arg1 = Double.parseDouble(node.getArg1());
double arg2 = Double.parseDouble(node.getArg2());
double sum = arg1 + arg2 ;
System.out.print("Their sum: " + sum);
That is how I would code it.
java.lang.System.out" would allow reference to "out" without qualification.