Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8969375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:34:57+00:00 2026-06-15T17:34:57+00:00

I am using bluej to make a program for userlists. When i compile and

  • 0

I am using bluej to make a program for userlists.
When i compile and run the code bluej does not give anny errors.
But when i make a new instance of a class it looks like nothing happens.
Printing a line to my terminal window from my instance does not work.
How can i make my instance print show in my terminal window?

   import java.util.*;
   import java.text.*;

   public class Main{
       private ArrayList<List> userlists;
       public Main(){
          System.out.print('\f');
          System.out.println("this text will show.");
          newlist("listname");
       }
       public void newlist(String listname){
          System.out.println("this text will show too!");
          List userlist = new List(listname); //terminal does not show lines printed by constructor of List?
          userlists.add(userlist);
          userlist.printSomeText(); //second attempt to print a line, does not show in terminal.
       }
    }

    public class List {
        private String listname;
        public List(String ln) {
            listname = ln;
            System.out.println("this text does not show.");
        }
        public void printSomeText(){
            System.out.println("this text neither.");      
        }
    }

I Run this by (first compiling both classes and then) rightclicking on the Main class in bluej’s interface and choosing new Main(). When i do this a terminal window shows up showing:

this text will show.
this text will show too!

but it does not show:

this text will show.
this text will show too!
this text does not show.
this text neither.

It does not show anny error’s so i would like to know whats going wrong and how to get the second result, showing those four lines.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:34:57+00:00Added an answer on June 15, 2026 at 5:34 pm

    First of all you dont have two public class in the same Java file.

    Second you must have to initialize the variable before using that variable or field, which is not happening in your question. I have done some modification in your code that will work according to you and also print the second bunch of lines, which you want to print.

    import java.util.ArrayList;
    
    public class Main {
        private ArrayList<List> userlists;
    
        public Main() {
            userlists = new ArrayList<List>();
            System.out.print('\f');
            System.out.println("this text will show.");
            newlist("listname");
        }
    
        public void newlist(String listname) {
            System.out.println("this text will show too!");
            List userlist = new List(listname); // terminal does not show lines
                                                // printed by constructor of List?
            userlists.add(userlist);
            userlist.printSomeText(); // second attempt to print a line, does not
                                        // show in terminal.
        }
    
        public static void main(String ... args){
            new Main();
        }
    }
    
    class List {
        private String listname;
    
        public List(String ln) {
            listname = ln;
            System.out.println("this text does not show.");
        }
    
        public void printSomeText() {
            System.out.println("this text neither.");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm teaching myself JavaScript using Code Academy and I'm trying to make some simple
This is my code.I am trying to make the ball move using arrow keys.
I'm trying to make a program that will draw lines over a picturebox using
I am using this code to make my form (FormBorderStyle=none) with rounded edges: [DllImport(Gdi32.dll,
I am doing a piece of coursework in Java using BlueJ. We need to
I have been using the default colors Grey and Blue for cell selection, but
Ok, I'm trying to make a program that finds the position of a colored
I would like to make a layout using Java Swing which looks like the
I would like to make this multidimensional array more readable by using one of
I'm wanting to make a component that inherits from rotate canvas using a storyboard.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.