Dave's Brain

Browse - Programming Tips - Why do I get "attempting to assign weaker access privileges; was public" when I override toString() ?

Date: 2012sep26
Language: Java

Q.  Why do I get "attempting to assign weaker access privileges; was public" when I override toString() ?

[javac] MyClass.java:NN: error: toString() in MyClass cannot override toString() in Object [javac] String toString() { [javac] ^ [javac] attempting to assign weaker access privileges; was public
A. You just need to change
@Override String toString() {
to
@Override public String toString() {

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.