• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Bear Bibeault
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Jj Roberts

Object Arrays

 
Ranch Hand
Posts: 250
1
Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




The printout is:
0
0

Why is this? Didn't I just set both radii to 50? It acts like it's ignoring the method calls from class Circle.
 
Bartender
Posts: 4568
9
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a closer look at your Circle.setRadius method. It isn't doing what you think it's doing.
 
Joel Christophel
Ranch Hand
Posts: 250
1
Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks once again
 
Ranch Hand
Posts: 326
Android Mac OS X Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Matthew Brown wrote:Have a closer look at your Circle.setRadius method. It isn't doing what you think it's doing.



Classic... I once spent 3 days trying to find one of those errors. ;)
 
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ove Lindström wrote:Classic... I once spent 3 days trying to find one of those errors. ;)


Yes... given that compiler also don't warn on such situations.
 
Ove Lindström
Ranch Hand
Posts: 326
Android Mac OS X Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

John Jai wrote:

Ove Lindström wrote:Classic... I once spent 3 days trying to find one of those errors. ;)


Yes... given that compiler also don't warn on such situations.



Exactly. But both PMD and FindBugs detects it so they are used in most of my continuous integration environments nowadays.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you are declaring:

but you are assigning in setRadius as


By default the variable which is integer is 0; so it displays 0;
write as:

 
We can walk to school together. And we can both read this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic