Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!

Jitender Raghuvanshi

+ Follow
since Mar 28, 2014
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jitender Raghuvanshi

The best way to do it is by using MVC (Model View Controller) architecture.
Read about it!
You would learn in no time...
8 years ago
Add it to a compressed folder and mail it yourself, if DropBox isn't working.
8 years ago
"Think in java" by Bruce Eckel.
The fourth edition covers it all.

Campbell Ritchie wrote:That might print negative numbers right, but I think it is no better as a solution, I am afraid.

how about using this method ->>Integer.toBinaryString();
Would it help??
8 years ago

Davey Lopez wrote:Question I thought you had to type super() to actually use a method from the base class

Objects of base class can access the superclass as well. super() is useful when you are transferring data to the superclass constructor from its baseclass (or simply invoking the superclass constructor in the baseclass) .
8 years ago
You have two constructors in your superclass.
Your object s is referencing the superclass as well.
So, when you are creating an object of your base class its first invoking the Constructor of the superclass.

The Superclass constructor initializes the x to 0 and prints the statement "Method 1".
Then control goes back to base class printing the statement "here dummy".
Afterwards, control comes back to main and s.x accesses the variable x of superclass and prints it.

So basically s.x and t.x are accessing the fields of your superclass.
Please do tell me if i am wrong... I am a beginner too. :-(
8 years ago

Jeanne Boyarsky wrote:Jitender,
Posting a code snippet is fine. Posting a hint is fine.

In other forums, we are ok with more in the answer. For example, the JavaScript forum often gets small working examples.

Yeah! Right. But now I understood the difference between other forums and this one.
Others simply give you answers while this one help developing your logical ability as well.
I appreciate the efforts being made here...
8 years ago

Campbell Ritchie wrote:Thank you for your comments. If somebody is trying to learn, they will be much more successful and remember the lesson better if they have worked it out for themselves. Simply giving a complete answer shortcircuits the process and ensures they do not know what to do next time such a problem arises.
We usually delete such posts (sometimes retaining the content so they can be restored later), but your posts both have instructive points about things which need improvement, so they are worth leaving.

We do actually care about beginners' questions; they usually go into a different forum, where we tell people this:-

We're all here to learn, so when responding to others, please focus on helping them discover their own solutions, instead of simply providing answers.

We have not done that to annoy you so sorry if we have. But turning up on a new forum, ignoring its conventions and calling people rude is really going to endear you to everybody, isn't it.

I get it now. But, you should display these rules while people register in here (Just a suggestion). Why would anybody go find the rules before entering a forum? I mean, nobody does that on web. You must make them read the rules. Rules and regulations should be displayed on top of everything. I hope you get my point.

8 years ago

Winston Gutkowski wrote:

Jitender Raghuvanshi wrote:and you wont explain what is wrong with the code?
That's rude! :P

As rude as not reading our HowToAnswerQuestionsOnJavaRanch (←click) page before posting an answer?

Because if you had, you'd have seen our version of the Hippocratic oath: FirstRuleDoNoHarm (the first link).
And also: DontBeACodeMill.

However, I'm sure your intentions were great, and welcome to the Ranch, Jitender.

Anyway, its working fine at my end.

Except, as Campbell said (and I mentioned earlier), that code will NOT give you what you expect with negative numbers.


Thanks Winston.
My intentions were clearly to give an answer for the question as i expect from people when i ask questions in other forms.
Clear, to the point answers!!!
By looking at previous answers i was sure that nobody gives a damn here about such beginner level questions(Everybody was like 'I am so fudging "Java Cool'").
But, as i am also a beginner , I actually do give a damn.
And that is what i was doing. And for giving a damn, i don't need to read any damn rules. Do I?
I know, Right? That is why I didn't go through any stupid rulebook before posting here. I simply gave the answer even if it was wrong for some extent (Which i am thankful to you both for noticing ).


8 years ago

Campbell Ritchie wrote:I may have seen an error which is not there. Sorry. But have you tried it with -123?

Hey! Thanks for the correction.

Try it now...

8 years ago

Campbell Ritchie wrote:Welcome to the Ranch

We usually discourage people from posting the whole solution before the OP has a good chance to work it out, and delete posts or parts of posts which contain entire solutions, but I have decided to leave that code so people can see why it will not work properly.

and you wont explain what is wrong with the code?
That's rude! :P
Anyway, its working fine at my end.
8 years ago
Well, all i can understand is that you want to print a binary number of whatever you pass into the method.
Even i am a beginner in java and in love with Java Collections.
So i just used Collections to solve this problem. I hope it helps.
And i actually don't know how to post codes here. So just copy pasting.

8 years ago