I'm interested in majoring in statsitics in my university as an under-grad. I am wondering whether I need to be a good programmer to do statistics because I really struggled in python and java even though I studied them for 1.5 years.
You increase your chances of getting hired in the industry very significantly if you can code well. You will also be able to ask for much higher salary. Overall, if you keep struggling then your options will be very limited not only at the start but throughout your career.
Now what is a "good programmer"? You don't have to be as good as professional programmers, but you must be able to code any algorithm you came up with. It may not be the best written code, but it must do what's required in terms of the logic of the algorithm. For a statistician that's the definition of "good" in my opinion. You should be able to implement any statistical algorithm and method that you studied so far, that's your measure of how good you are.
UPDATE: To your struggles with Java: that's not a typical stat language, so I wouldn't hold this against you. Python is used in data science a lot, but look at who uses it: mainly people with some kind of a programming background. Some statisticians like Python, of course, but it is (like Java and C++) a system programming language. I'd call it a "proper programming language", i.e. one that even pro programmers use without reservations. What I'm trying to say is that mere fact that you're struggling with these two particular languages is not yet a sign of an issue. However, if you struggle with programming in any language (any that you tried) then you have to think about the future in this profession seriously.