473,394 Members | 1,765 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

help with java printing

I am writing a new class... here is what I have so far

public class SmallBank
{
private BankAccount account1;
private BankAccount account2;

public SmallBank(String name, int balance)
{
account1 = new BankAccount(name, balance);
}

public void addAccount(BankAccount account2)
{
this.account2 = account2;
}

the next step is to print out the details of account 1, but when I do the system.out.println(account1), it prints BankAccount@1d5a0200200. I want it to print the Name and Balance, which are the details in account1. Can someone tell me what i'm doing wrong?
Feb 6 '07 #1
1 1135
r035198x
13,262 8TB
I am writing a new class... here is what I have so far

public class SmallBank
{
private BankAccount account1;
private BankAccount account2;

public SmallBank(String name, int balance)
{
account1 = new BankAccount(name, balance);
}

public void addAccount(BankAccount account2)
{
this.account2 = account2;
}

the next step is to print out the details of account 1, but when I do the system.out.println(account1), it prints BankAccount@1d5a0200200. I want it to print the Name and Balance, which are the details in account1. Can someone tell me what i'm doing wrong?
Is there a toString() method in the BankAccount class that you have not posted? In that methods you should return a string representing the name and balance of the account, then to show this data you print using
Expand|Select|Wrap|Line Numbers
  1.  System.out.println(account1.toString());
Feb 6 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Rami | last post by:
Hello all, Java has some printing problems with hp pcl5e and pcl6 drivers. I have one another printer that is defined just as "...PCL series", and this printer prints java output correctly. So, I...
5
by: java_helloworld | last post by:
I am trying to print from an applet using the Java Print API. If I run the applet on appletviewer then things work fine i.e. I am able to get the print out. If I run the applet on a browser then...
2
by: Jean Paul | last post by:
Does anyone knows of an good tutorial for printing in java? Thnx
4
by: Tarique Jawed | last post by:
Alright I needed some help regarding a removal of a binary search tree. Yes its for a class, and yes I have tried working on it on my own, so no patronizing please. I have most of the code working,...
2
by: Chris | last post by:
Hi, I seem to be having some problems connecting to webservices. I'm running a C# client connected to a Java webservice using GLUE. The difference between the two request and response pairs...
4
by: jodi | last post by:
Hi, I am really newbie in Java I need to build an applet that prints a text, but, it can not roll the page I mean, when I print like "TEST ONE TEST TWOO TEST THREEE" the printer can not roll...
3
by: Simon Brooke | last post by:
As various people will have noticed, I've been having a lot of trouble with XSL lately. Brief history: I wrote myself an XML toolkit back in 2000, and it worked well enough for me, so it's been...
8
by: garyrowell | last post by:
I have been at this programme for hours trying to work out what is wrong. Any help would be very much appricated. Here is the breif I received. The program This week you are going to write three...
0
by: doobybug | last post by:
Hi all, I really need your help! I am new to java and have some problems with my code. I have a program which inputs questionnaires and creates an object for each questionnaire. These objects are...
49
by: aarklon | last post by:
Hi all, See:- http://www.cs.princeton.edu/introcs/faq/c2java.html for C vs Java in number crunching http://husnusensoy.blogspot.com/2006/06/c-vs-java-in-number-crunching.html
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.