• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How do i print in java

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do i print in java
+
how do i print contents of listbox!
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

------------------
 
What's gotten into you? Could it be this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic