• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how public data member manipulated by outside world

 
Abdullah mohammad
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


please can some one give an example in which public data member of a class is manipulated by outside world
directly.
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The java.awt.Point class (see API) has two public data members, x and y. You can directly manipulate them like this:
 
Campbell Ritchie
Sheriff
Pie
Posts: 49365
62
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch
Look up the java.awt.Point class. Or java.awt.GridBagConstraints.
Of course, it is usually regarded as poor design to have public fields, unless they are constants. Point and GridBagConstraints do not escape being bad.
 
Abdullah mohammad
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve Luke wrote:The java.awt.Point class (see API) has two public data members, x and y. You can directly manipulate them like this:



thank you Steve
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic