Question

I am trying to concatenate two strings using groovy shell but it's not working

   groovy.shell("def name = 'MyName'; def fname = 'firstName'; println name+fname" );

But for single string this is working

   groovy.shell("def name ='MyName'; println name");

Any idea about this?

Was it helpful?

Solution

You can Use StringBuilder as below Object value = shell.evaluate("def name= new StringBuilder('James'); def fname= new StringBuilder('abd'); println name.append(fname) ;");

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top