How do I convert this python code to java?
Here’s the python source code (Animal class):
class Animal:
#final string for whole string
final_string = “”
#constructor and setting the values
def __init__(self, name, gut):
self.name = name
self.gut = gut
#greet method
def greet(self):
print (“Hello my name is ” + self.name + “.”)
#I am user inputting the eatables of animals for reference
self.gut = input(“enter the animal eatables: “).split()
#printing the animal:name
def __str__(self):
#if length is zero, return empty. return animal:name is digestingnothing
if len(self.gut) == 0:
return “Animal: ” + self.name + ” is digesting nothing.”
else:
string = “Animal: ” + self.name + ” is digesting “
for i in range(len(self.gut)):
”’
i == len(self.gut)-2: if current
OR
OR