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

  • SEARCH
  • Home
  • 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 7689879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:16:00+00:00 2026-05-31T20:16:00+00:00

i am new to java, and would like some advice on the following i

  • 0

i am new to java, and would like some advice on the following

i have two files:

SongsList.java and SongsMenu.java

SongsMenu.java (http://pastie.org/private/cm0zpembkqnfjif0pgdadq) lines 38 / 39

import java.util.Scanner;
import java.util.InputMismatchException;

public class SongsMenu {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);

...

switch (listMenuItem) {
case 1:
System.out.println("Album");
SongsList sl = new SongsList();
System.out.println(sl);
    break;

and SongsList.java (http://pastie.org/private/qljonhfdronvbq4ahcqgmq)

public class SongsList {

public static void main(String args[]) throws Exception {
    // reads the file and returns a list of my Music.txt file
    ...

when i run the SongsList, i get:

 $java SongsList
 Track 58                   Reggae  1637918 81          58  59      18/02/2010 21:02    28/01/2012 14:07    160 44100       MPEG audio file                             khinester:Users:khinester:Music:iTunes:iTunes Music:Unknown Artist:Unknown Album:58 Track 58.mp3
 Track 59                   Reggae  4239191 211         59  59      18/02/2010 21:02    28/01/2012 14:07    160 44100       MPEG audio file                             khinester:Users:khinester:Music:iTunes:iTunes Music:Unknown Artist:Unknown Album:59 Track 59.mp3

 ...

but when i run the SongsMenu

$java SongsMenu
  1) Album
  ...

1
Album
SongsList@50ef5502

How do i return the list, instead of ‘SongsList@50ef5502’ i would like to ultimately be able to list this in order of Album, Name and make searches.

Any advice much appreciated.

  • 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-05-31T20:16:02+00:00Added an answer on May 31, 2026 at 8:16 pm

    The problem is with this line

    ::line number 39 System.out.println(sl);
    

    If you try to print an object, it will only print the hashcode of the given object.

    Better rewrite the program as further explained:

    You can move you logic into a method and explictly call the method (or move the logic into default contructor), for example:

    Songlist Class should be like this:

    public class SongsList {
        public SongsList(){
            runMyCode();
        }
        public void runMyCode(){
            // SongList logic here
        }
    }
    

    And call songlist in songsmenu like this:

    case 1:
        System.out.println("Album");
        SongsList sl = new SongsList();
        s1.runMyCode();
        // do something...
            break;
    

    Hope this will help you. Better learn some OOP concepts buddy… It is bad to have doubts in such a basic Java code.
    Try to learn java from Head first java book: Head First Java.pdf

    It is quite simple and fun to learn it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to java programming and I would like to work on some kind
I am very new to Java. I would like to use some features from
I would like some Java code to Delete files older than N days. Here
I have some TODO tags in my Java code and would like to parameterize
I am new to Java, the function I would like to perform is to
When creating a new Java project in IntelliJ IDEA, the following directories and files
I have some C# experience, but im completly new to java. So i have
I am fairly new to Java programming, and would like to know how to
I am a new to programming with Java and I would like to know
I am new to Java and I would like to know which would be

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.