Win a copy of Python Continuous Integration and Delivery this week in the Python forum!

salvin francis

Bartender
+ Follow
since Jan 12, 2009
salvin likes ...
Eclipse IDE Google Web Toolkit Java
Forum Moderator
salvin francis currently moderates these forums:
Mumbai
Cows and Likes
Cows
Total received
92
In last 30 days
12
Total given
118
Likes
Total received
265
Received in last 30 days
13
Total given
133
Given in last 30 days
19
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by salvin francis

Nan Jordan wrote:... the method got called in line 16 should be from class Clownfish.


You're absolutely right, during runtime, the method from Clownfish will be called. You can verify it by writing the following code:

Nan Jordan wrote:...But the method getFish() in Clownfish does not throw any exceptions.

From the compiler's perspective, "f" is  a "Fish" and hence you see a compile error. Remember, your code can be also written as :
19 hours ago

Nan Jordan wrote:...but the first one is using base class version which got a compile error on line 16...

Hi,
Let me share the compile error just to be clear :
As per the method signature, the getFish() method can throw a BubbleException. Hence, java is not sure about what to do when such error is thrown and is asking you to write code to handle it. As per the error message, there are two ways to do it. Either declare a try-catch block around it or change the main method signature to throw a BubbleException.

Nan Jordan wrote:However, the second program is using subclass version, output is "DerivedA". Why is that? ...


In your second program, b2 is a reference of type "Base", but, the object it points to is of type "DerivedA". This is why when the test method is called, the method from "DerivedA" is executed. Here's a good tutorial on Polymorphism that explains this behavior: https://docs.oracle.com/javase/tutorial/java/IandI/polymorphism.html

Java Tutorial wrote:The Java virtual machine (JVM) calls the appropriate method for the object that is referred to in each variable. It does not call the method that is defined by the variable's type. This behavior is referred to as virtual method invocation and demonstrates an aspect of the important polymorphism features in the Java language.



1 day ago
I have some proof


1 week ago
Okay, let me ask you a different question...
Why do you think the answer is "yes" to question1 ?
and
Why do you think the answer is "m1" or "m1 and m2" to question2 ?
2 weeks ago
It would not take you more than 5 minutes to actually type out this code and try it on your machine. It would also show that you have ShownSomeEffort in asking your question.
Specifically: "Put as much effort into presenting your question as you would hope someone will put into answering it. "

I would not suggest guessing an answer as it would benefit no one.
2 weeks ago
I would suggest reading about variables and Classes and Objects
Once you're confident with these concepts, you would be able to write your program with ease.

2 weeks ago
These are the errors I see when compiling your class:



And ... Welcome to code ranch !!
2 weeks ago

cal lockrun wrote:public class Shape ()
{
  public static final PI = 3.14
}
so far no compile errors



Are you sure this would compile ? First of all, a class does not have "()" there.
Next, what is "PI" in the above code ? is it a float or a double ?
2 weeks ago

Junilu Lacar wrote:...To a client, it would make more sense if I just got an iterator that I could go through all the spaces in a row-wise manner.


Okay, let's agree to disagree I still think that a nested array would still be good instead of creating a 1 dimensional iterator, additionally, I would return a copy of the array (Effective java:Make defensive copies when needed)
Maybe we could meet mid way and agree on an iterator of MarksRow ? (a bit overkill for a 3x3 cell game)
2 weeks ago

cal lockrun wrote:... I need help with creating circle ...



Hi, What kind of help are you looking for ?
Surely you don't want us to write the complete code for you. Are you unable to declare a class or an instance variable ?
I suggest having a look at HowToAskQuestions. Specifically, NotACodeMill and ShowSomeEffort

2 weeks ago

Junilu Lacar wrote:...I would suggest a method, say iterator(), that returns an Iterator instead and that documentation be explicit about the order in which the iterator goes ...


Interesting, I usually do not use an Iterator for a 3x3 board. Are we taking about linear iteration (top left to bottom right)?  
Also curious, why isn't a multidimensional array good for a board of rows and columns ?

I agree that "entry" is a technical term, maybe I can think of a better name. Also noughtsAndCrosses was not a domain object, it is the game controller. My idea about this game is to define a controller (or an engine) that maintains its own state and allows the state to be changed by calling methods on it. It would ensure that the game rules are followed and it would never go into an undesirable state.

A UI based implementation would query for the states of all entries in the controller and refresh itself to match the returned value.

2 weeks ago
Let me throw in my suggestion about a NoughtsAndCrosses class that can be used for a CUI or a GUI board game:

2 weeks ago
Hi Nathan,
Bear is right, you need to share the exact stack trace so that we can help you out. If you have trimmed out your code just to post it here, does the trimmed code throw the same exception ? This could save us a lot of time trying to debug a code that does not throw any exception  It would also show us that you have showed some effort

Nathan Milota wrote:... where I declare the Statement variable, and down in the doPost method where I do it does the process request.  There is a null pointer exception in those spots.


I think the con object can be null. A simple System.out.println() would not reveal things more better.
2 weeks ago
Unless I have completely misunderstood OP's question, here's a simple regex I wrote:

3 weeks ago
I think you meant :
you missed the space in SPACE.
3 weeks ago