Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes How do i print in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How do i print in java" Watch "How do i print in java" New topic
Author

How do i print in java

Jimmy Thakkar
Greenhorn

Joined: Oct 03, 2001
Posts: 2
How do i print in java
+
how do i print contents of listbox!
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

To print to the console ( i.e. the OS window the java program is running in... ) use


Is the class you are trying to print the contents of a List ( in java.awt ) or a JList ( in javax.swing )?

-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
shweta agarwal
Greenhorn

Joined: Aug 30, 2001
Posts: 10
to print anything use:
System.out.println("string1" + "string2" + variables);
u can thus overload + operator to get the expression of ur desire by making any combination.
u can also use System.out.print (instead of System.out.println) if u dont want to switch over to the next line after printing the stuff in the first line.
to print the contents of a listbox use the following 2 methods:
int countItem()
this returns the total number of items in the list.
and once u have the total number of items in the list u can use the following method in a loop
String getItem(int)
which returns the item at int position.
so ur code would be something like this(if ur list is l1)
int i = l1.countItem();
for(int j=0;j<i;j++)>
System.out.println(l1.getItem(j));

shweta agarwal
Sun Certified Programmer for the Java� 2 Platform

------------------
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do i print in java
 
Similar Threads
Printing jframe
how to print data from a java application
Print online Form using Servlets
Printing from android
Calling "winspool.drv" from Java