Translate

Friday 1 October 2021

Operator Overloading in Groovy Scripting groovy training telugu 16

 Watch This Video

https://youtu.be/7AGEdLF4_x8


---------------------------------------------------------------------------------------------------------------
https://groovy-lang.org/operators.html#Operator-Overloading


def a=10
def b=20
println a+b
println a.plus(b)


def s1="Hello"
def s2="world"
println s1+s2
println s1.plus(s2)


class Account{
BigDecimal balance
Account plus(Account other){
new Account(balance:this.balance+other.balance
}
String toString(){
"Account Balance: $balance"
}
}
Account savings=new Account(balance:500)
Account checkings= new Account(balance:100)

println savings+checkings

No comments:

Post a Comment

Note: only a member of this blog may post a comment.