How to use Iterator correctly to print out object attributes from Vector ?
Dear Java People,
I have no compilation errors but am not getting output.
I created a CD class and a Vector to hold all the CDs.
I think perhaps I am using the Iterator incorrectly in the
toSting() method. Below is the driver and CD class
Thank you in advance
Norman
import java.util.*;
public class TryCD
public static void main(String[] args)
Vector cdVector = new Vector();
CD cd_1 = new CD("Heavy Rapper", "Joe", true);
CD cd_2 = new CD("Country Music", "Sam", true);
CD cd_3 = new CD("Punk Music", "Mary", true);
cdVector.add(cd_1);
cdVector.add(cd_2);
cdVector.add(cd_3);
Iterator i = cdVector.iterator();
while(i.hasNext())
i.next().toString();
public class CD
private String item;
private boolean borrowed = false;
private String borrower = "";
private int totalNumberOfItems;
private int totalNumberOfItemsBorrowed;
public CD(String item,String borrower, boolean borrowed)
this.item = item;
this.borrower = borrower;
this.borrowed = borrowed;
public String getItem()
return item;
public String getBorrower()
return borrower;
public boolean getBorrowed()
return borrowed;
public String toString()
return getItem() + getBorrower();
}
Dear InTrueT,
The problem with trying to use
System.out.println()is that it returns void and
toString() requires a String be returned
the error messaage says:
"CD.java": Error #: 354 : incompatible types; found:
void, required: java.lang.String at line 35
your advice is appreciated
NormanYou seem to have misunderstood. toString(), as you say, returns a String. System.out.println(), by a wonderful coincidence of design, accepts a String as a parameter. My suggestion was that you pass the output of one as the input to the other, thus displaying your String on the screen, as I had understood this to be your desire.
Similar Messages
-
When attempting to print a 4X6 photo using Elements 12 it prints out 2X3. Does anyone know how you can get hold of a live person at Adobe?
I've never done a forum and am not exactly sure what to do from here. I
know how to do a screen shot on my phone, but not on my computer.
I'm about ready to throw every adobe product I have out the window! If
you purchase a product you should be able to get support from the company.
In a message dated 4/6/2015 3:04:02 P.M. US Mountain Standard Time,
[email protected] writes:
When I try to print a 4X6 photo using Elements 12 it prints out 2X3.
Does anyone know how you can get hold a live person at Adobe?
created by Peru Bob (https://forums.adobe.com/people/Peru+Bob) in
Photoshop Elements - View the full discussion
(https://forums.adobe.com/message/7412463#7412463) -
How to print out multilingual reports from the main report using Xliff temp
Hi all,
How to print out multilingual reports from the main report using Xliff temp?
When I want main report call subtemplate and finish xliff tranlation
<?for-each@section:INVOICE?><?end for-each?>
<?import:xdo://XXIH.XXNR_XXINVPRINT_SUB.en.FI/?>
<?start:body?><?call:Header?><?call:Line?><?call:Weights?><?call:Banks?><?end body?><?call:Footer?>
Prints out fine with Finnish translation
But if I want in main program to check what language is used e.g.
if trx_number = 142 call Finnish translation and if trx_number =144,
call English translation.
<?for-each@section:INVOICE?><?end for-each?>
<?if:TRX_NUMBER=’142’?>
<?import:xdo://XXIH.XXNR_XXINVPRINT_SUB.en.FI/?>
<?start:body?><?call:Header?><?call:Line?><?call:Weights?><?call:Banks?><?end body?><?call:Footer?>
<?end if?>
<?if: TRX_NUMBER=’144’?>
<?import:xdo://XXIH.XXNR_XXINVPRINT_SUB.en.US/?>
<?start:body?><?call:Header?><?call:Line?><?call:Weights?><?call:Banks?><?end body?><?call:Footer?>
<?end if?>
Prints out always in English and never the Finnish translation.
Program goes fine to if branch but does not print out Finnish
Does anybody know what could be wrong?
BR
KariThanks Amit,
I have two layout, main-layout and sub-layout
Main layout call subtemplate
I have registered layout and xliff-file
Main template
Localized Templates
File Name Language Territory
XXNS_INVOICE_MAIN.rtf English
SUB template
Localized Templates
File Name Language Territory
XXNS_INVOICE_SUB.rtf English
Translatable Template
File Name Language Territory
XXNS_INVOICE_SUB.rtf English United States
Available Translations
Language Territory Progress
English Finland Complete
If main report call subtemplate and finish xliff tranlation
<?import:xdo://XXIH.XXNR_XXINVPRINT_SUB.en.FI/?>
Prints out fine with Finnish translation
But if I want in main program to check what language is used e.g.
if....
<?import:xdo://XXIH.XXNR_XXINVPRINT_SUB.en.FI/?>
.....end if;
if....
<?import:xdo://XXIH.XXNR_XXINVPRINT_SUB.en.US/?>
.....end if;
Prints out always in English and never the Finnish translation.
Program goes fine to if branch but does not print out Finnish
Do you it's set up problem or program problem
BR
Kari -
How do I print out the attributes of objects from a Vector? Help !
Dear Java People,
I have created a video store with a video class.I created a vector to hold the videos and put 3 objects in the vector.
How do I print out the attributes of each object in the vector ?
Below is the driver and Video class
Thank you in advance
Norman
import java.util.*;
public class TryVideo
public static void main(String[] args)
Vector videoVector = new Vector();
Video storeVideo1 = new Video(1,"Soap Opera", 20);
Video storeVideo2 = new Video(2,"Action Packed Movie",25);
Video storeVideo3 = new Video(3,"Good Drama", 10);
videoVector.add(storeVideo1);
videoVector.add(storeVideo2);
videoVector.add(storeVideo3);
Iterator i = videoVector.interator();
while(i.hasNext())
System.out.println(getVideoName() + getVideoID() + getVideoQuantity());
import java.util.*;
public class Video
public final static int RENT_PRICE = 3;
public final static int PURCHASE_PRICE = 20;
private int videoID;
private String videoName;
private int videoQuantity;
public Video(int videoID, String videoName, int videoQuantity)
this.videoID = videoID;
this.videoName = videoName;
this.videoQuantity = videoQuantity;
public int getVideoID()
return videoID;
public String getVideoName()
return videoName;
public int getVideoQuantity()
return videoQuantity;
}Dear Bri81,
Thank you for your reply.
I tried the coding as you suggested
while(i.hasNext())
System.out.println( i.next() );
but the error message reads:
"CD.java": Error #: 354 : incompatible types; found: void, required: java.lang.String at line 35
Your help is appreciated
Norman
import java.util.*;
public class TryCD
public static void main(String[] args)
Vector cdVector = new Vector();
CD cd_1 = new CD("Heavy Rapper", "Joe", true);
CD cd_2 = new CD("Country Music", "Sam", true);
CD cd_3 = new CD("Punk Music", "Mary", true);
cdVector.add(cd_1);
cdVector.add(cd_2);
cdVector.add(cd_3);
Iterator i = cdVector.iterator();
while(i.hasNext())
System.out.println( i.next() );
public class CD
private String item;
private boolean borrowed = false;
private String borrower = "";
private int totalNumberOfItems;
private int totalNumberOfItemsBorrowed;
public CD(String item,String borrower, boolean borrowed)
this.item = item;
this.borrower = borrower;
this.borrowed = borrowed;
public String getItem()
return item;
public String getBorrower()
return borrower;
public boolean getBorrowed()
return borrowed;
public String toString()
return System.out.println( getItem() + getBorrower()); -
How to print out a date from the past
I am trying to print out a date from the past but I cant seem to get It,
Lets use for example Independece Day,
How would you write the code in order to print out that exact date?Look at the
[url=http://java.sun.com/javase/6/docs/api/index.html?
java/util/Date.html]Date APIActually the Calendar class would be better to use, since you can set all the different fields from year to second, plus things like day of week, day of month, week of year, etc.
too slow
Message was edited by:
hunter9000 -
How can I print out my contacts from my ipad
HHow can I print out my contacts from my iPad or iPhone?
Hi Ken, there is an app, Contact Sheet (http://itunes.com/apps/appiota/contactsheet) that will not only print your contacts, it can also print the pictures! This app can be used to back up, share, or extract information from your contacts. You can select which contacts to use by creating a group and you can choose which fields to include. So, for example, if you were creating a phone list to distribute to your bowling group, you could just include names and phone numbers and not include address or other information that people may not want shared. It can even be used to send group emails and group text messages. Please check it out!
-
Why can't I get my printer to print out a playlist from i-tunes? It used to work, but now the printer doesn't seem to recognize the "print" command coming from i-tunes. The printer works for other applications!
I finally solved this problem after toiling with it for a couple of days. Solution: Once you have burned your CD you must go back into iTunes to your music/playlists and select the playlist you just burned and click file; print and you will get the mosaics that we have been accustomed to. I was on hold with Apple Support when I found this myself. Yes......!!! Problem solved..for me anyway. Good luck!
Scott -
HT4356 How to use Canon Selphy Photo Printer (CP900) to print from iPad 3?
How to use Canon Selphy Photo Printer (CP900) to print from iPad 3? I would like to print the photos in my ipad on my Canon Selphy Photo Printer (CP900) which has wifi...
hi
ideally if you want to print from the ipad you should have an airprint enabled printer:
http://support.apple.com/kb/ht4356
however, there are workarounds, you can download a decent third party app to print such as print n share, printcentral or printdirect -
How do you geT ICal to print out the To Do Items in the same order as you have sorted them on the screen
Without actually seeing some of what is in the .ics attachment there's really no way to see what's going on.
-
How to take sub-contracting challana print out
Hai friends,
How to take sub-contracting challana print out.
Where i have to do the message settings for taking return delivery excise document print out ( rejected RM material return to vendor ).
Please guide me.Hello,
During creation of 57F4 Challan in J1IF01, in Basic Data Tab Page, scroll down the screen, you will get a check box of "Print immediately" just activate it before saving, it will print the Subcontracting challan once you save it.
And to re-print the same go to J1IF11 and activate this indicator again and save.
Configuration Checks: -
SPRO > Logistics - General > Tax on Goods Movements > India > Business Transactions > Subcontracting > Subcontracting Attributes > Check whether Subcon Output Type - J1IF is maintained here.
Also check in M706 - For Output Type - J1IF should be in place.
Note: - There is no need of maintaining condition record for output type J1IF in MN21 and also no need to do any further configuration.
Maintain printer in the SPRO - IMG - MM - Inventory management - Output determination - printer determination.- printer determination by plant / storage location ( OMJ3). Here for the application area ME, condition type J1IF, assign the printer.
regards, -
How to print out the data from the file ?
hi all,
i have upload my file to here :
[http://www.freefilehosting.net/ft-v052010-05-09 ]
anyone can help me to print out the data from the file ?
the content of the file should be like this :
185.56.83.89 156.110.16.1 17 53037 53 72 1
and for the seven column is
srcIP dstIP prot srcPort dstPort octets packetshi all,
i have try to do this
public static void Readbinary() throws Exception
String file = "D:\\05-09.190501+0800";
DataInputStream dis = new DataInputStream(new FileInputStream(file));
//but then how to read the content ??????can you give me more hint ?????
i have find the netflow v5 structure by C
struct NFHeaderV5{
uint16_t version; // flow-export version number
uint16_t count; // number of flow entries
uint32_t sysUptime;
uint32_t unix_secs;
uint32_t unix_nsecs;
uint32_t flow_sequence; // sequence number
uint8_t engine_type; // no VIP = 0, VIP2 = 1
uint8_t engine_id; // VIP2 slot number
uint16_t reserved; // reserved1,2
struct NFV5{
ipv4addr_t srcaddr; // source IP address
ipv4addr_t dstaddr; // destination IP address
ipv4addr_t nexthop; // next hop router's IP address
uint16_t input; // input interface index
uint16_t output; // output interface index
uint32_t pkts; // packets sent in duration
uint32_t bytes; // octets sent in duration
uint32_t first; // SysUptime at start of flow
uint32_t last; // and of last packet of flow
uint16_t srcport; // TCP/UDP source port number or equivalent
uint16_t dstport; // TCP/UDP destination port number or equivalent
uint8_t pad;
uint8_t tcp_flags; // bitwise OR of all TCP flags in flow; 0x10
// for non-TCP flows
uint8_t prot; // IP protocol, e.g., 6=TCP, 17=UDP, ...
uint8_t tos; // IP Type-of-Service
uint16_t src_as; // originating AS of source address
uint16_t dst_as; // originating AS of destination address
uint8_t src_mask; // source address prefix mask bits
uint8_t dst_mask; // destination address prefix mask bits
uint16_t reserved;
but how to translate the structure to java,then get the data from the file ?
Edited by: 903893 on Dec 21, 2011 10:52 PM -
How may I print out a picture from paper and not the photo tray?
How may I print out a picture from paper and not the photo tray?
From paper? Do you have a digital image of it on your iPhone?
"Photo tray"? What do you mean here? The iPhone does not have a photo tray. Printers have trays. -
Is it possible to print out Address Book from a 8310
Is it possible to print out Address Book from a 8310, I have backed it up using Desktop Manager. It is in a .ipd file. Is their anythin that will read an .ipd file? Thanks
Solved!
Go to Solution.Hi and Welcome to the Forums!
I've heard of a few...can't recall the exact names...Amber something or other? You might try googling to see if you can find anything.
Good luck and let us know!
Occam's Razor nearly always applies when troubleshooting technology issues!
If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
Join our BBM Channels
BSCF General Channel
PIN: C0001B7B4 Display/Scan Bar Code
Knowledge Base Updates
PIN: C0005A9AA Display/Scan Bar Code -
How to use the index method for pathpoints object in illustrator through javascripts
hii...
am using Illustrator CS2 using javascripts...
how to use the index method for pathpoints object in illustrator through javascripts..Hi, what are you trying to do with path points?
CarlosCanto -
How to use for all entires clause while fetching data from archived tables
How to use for all entires clause while fetching data from archived tables using the FM
/PBS/SELECT_INTO_TABLE' .
I need to fetch data from an Archived table for all the entries in an internal table.
Kindly provide some inputs for the same.
thanks n Regards
RameshHi Ramesh,
I have a query regarding accessing archived data through PBS.
I have archived SAP FI data ( Object FI_DOCUMNT) using SAP standard process through TCODE : SARA.
Now please tell me can I acees this archived data through the PBS add on FM : '/PBS/SELECT_INTO_TABLE'.
Do I need to do something else to access data archived through SAP standard process ot not ? If yes, then please tell me as I am not able to get the data using the above FM.
The call to the above FM is as follows :
CALL FUNCTION '/PBS/SELECT_INTO_TABLE'
EXPORTING
archiv = 'CFI'
OPTION = ''
tabname = 'BKPF'
SCHL1_NAME = 'BELNR'
SCHL1_VON = belnr-low
SCHL1_BIS = belnr-low
SCHL2_NAME = 'GJAHR'
SCHL2_VON = GJAHR-LOW
SCHL2_BIS = GJAHR-LOW
SCHL3_NAME = 'BUKRS'
SCHL3_VON = bukrs-low
SCHL3_BIS = bukrs-low
SCHL4_NAME =
SCHL4_VON =
SCHL4_BIS =
CLR_ITAB = 'X'
MAX_ZAHL =
tables
i_tabelle = t_bkpf
SCHL1_IN =
SCHL2_IN =
SCHL3_IN =
SCHL4_IN =
EXCEPTIONS
EOF = 1
OTHERS = 2
OTHERS = 3
It gives me the following error :
Index for table not supported ! BKPF BELNR.
Please help ASAP.
Thnaks and Regards
Gurpreet Singh
Maybe you are looking for
-
Hi, In MIRO when the PO reference is selected as u201C PO /Sch Agreement u201C the default setting shows only the u201C Good/service items u201C . Can this be modified to u201CGood/service items + Planned delivery costsu201C . If yes how ? Please
-
Can I prevent my book opening with the contents page?
After the intro video I would like my book to open with the first page full screen, not with the contents. Is this possible? Thanks
-
Hello, We currently have completed implementation using SolMan and gone-live. From the operational side of things we have set up EWA and Maintenance Optimizer in our SolMan. We are planning to implement Business Process Monitoring (BPM) functionality
-
Ctrl-F4 closes two tabs, not one
Ctrl-F4 closes two tabs, not one. Ctrl-W is working fine. This is possibly due to a plugin / extension, as I have updated them / installed new themes recently.
-
My URL field disappeared.
How to change the layout on safari toolbar ? My url field in the toolbar disappeared.