I need to convert python code to java, can anyone help me

import random
import string

def printAll(conversation):
   for line in conversation:
       print (line)

def main():
   cannedlist = ["How are you?", "Why is the sky blue?" , "How's the
weather?" , "When will it end?" , "Why are we here?" , "Sounds good!",
"That's great!", "What time is it?"]
   num_canned = len(cannedlist)
   response = input("How many rounds of conversation?")
   conversation = []
   number = random.randrange(0,num_canned)
   computer = cannedlist[number]
   print (computer)
   conversation.append(computer)

   # perform specified number of interaction rounds
   for interaction in range(eval(response)):
       user = input("")
       conversation.append(user)

       # search for mirror words and construct response
       userwords = user.split()
       mirror_words_found = False
       computer = ""
       for word in userwords:
           if word == "I":
               new_word = "You"
               mirror_words_found = True;
           elif word == "you":
               new_word = "I"
               mirror_words_found = True;
           elif word == "You":
               new_word = "I"
               mirror_words_found = True;
           elif word == "am":
               new_word = "are"
               mirror_words_found = True;
           elif word == "are":
               new_word = "am"
               mirror_words_found = True;
           elif word == "me":
               new_word = "you"
               mirror_words_found = True;
           elif word == "you're":
               new_word = "I'm"
               mirror_words_found = True;
           elif word == "I'm":
               new_word = "You're"
               mirror_words_found = True;
           else:
               new_word = word
           computer = computer + new_word + " "
       computer = computer.replace(".","?");
       computer = computer.replace("!","?");

       # if we found no mirror words, use a canned response instead
       if not mirror_words_found:
           number = random.randrange(0,num_canned)
           computer = cannedlist[number]

       # use whatever response we came up with
       print (computer)
       conversation.append(computer)

   # end the conversation
   computer = ("Goodbye!")
   print (computer)
   conversation.append(computer)
   print()
   print()
   printAll(conversation)

main()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.