How is Java more secured than other languages?

because java is categorized into packages and packages contain classes which are not accessible directly.