Domanda

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?

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top