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 706461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:10:08+00:00 2026-05-14T04:10:08+00:00

I come from a PHP background and I’m just getting my teeth into some

  • 0

I come from a PHP background and I’m just getting my teeth into some Java. I was wondering how I could implement the following in Java as simply as possible, just echoing the results to a terminal via the usual “System.out.print()” method.

<?php
$Results[0]['title'] = "No Country for Old Men";
$Results[0]['run_time'] = "122 mins";
$Results[0]['cert'] = "15";
$Results[1]['title'] = "Old School";
$Results[1]['run_time'] = "88 mins";
$Results[1]['cert'] = "18";

// Will basically show the above in order.
foreach($Results as value) {
     echo $Results[$value]['title'];
     echo $Results[$value]['run_time'];
     echo $Results[$value]['cert'];
}

// Lets add some more as I need to do this in Java too

$Results[2]['title'] = "Saving Private Ryan";
$Results[2]['run_time'] = "153 mins";
$Results[2]['cert'] = "15";

// Lets remove the first one as an example of another need
$Results[0] = null;
?>

I hear there are “list iterators” or something that are really good for rolling through data like this. Perhaps it could be implemented with that?

A fully working .java file would be most handy in this instance, including how to add and remove items from the array like the above.

P.S. I do plan on using this for an Android App in the distant future, so, hopefully it should all work on Android fine too, although, I imagine this sort of thing works on anything Java related :).

  • 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-14T04:10:09+00:00Added an answer on May 14, 2026 at 4:10 am

    If I were doing that in Java I would make the following changes:

    1. Make a Movie class that encapsulates the data about a movie
    2. Use Lists instead of native arrays

    A Movie class may look something like this:

    public class Movie {
    
        public final String title;
        public final int runtime;
        public final int cert;
    
        public Movie(String title, int runtime, int cert) {
            this.title = title;
            this.runtime = runtime;
            this,cert = cert;
        }
    }
    

    Then you could make a List of Movies like so:

    List<Movie> movies = new ArrayList<Movie>();
    movies.add(new Movie("Some Movie", 120, 15);
    movies.add(new Movie("Another Movie", 90, 18);
    

    You can remove Movies like so:

    movies.remove(0);
    

    And you can iterate through them like so:

    for (Movie m: movies) {
        System.out.println("Title: " + m.title + 
                           ", Runtime: " + m.runtime + 
                           ", Cert: " + m.cert);
    }
    

    If you wanna get specific things out of the List, you can do the following:

    Movie the2ndOne = movies.get(1);
    System.out.println("Title: " + the2ndOne.title); // or
    System.out.println("Title: " + movies.get(0).title);
    

    To view an entire List simply do:

    System.out.println(movies.toString());
    

    Note: This assumes that the Movie class has an intelegent toString() method written for it.

    For some more reference on Lists that I showed above, check out the javadocs on them.

    When writing in a OO language, you should use OO principles.

    It may also be helpful to read this question and my answer to it. It is very similar in that you two are both trying to do things with arrays that would better be served using classes.

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

Sidebar

Ask A Question

Stats

  • Questions 342k
  • Answers 342k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You need to change this: display:block; To this: display:inline-block; block… May 14, 2026 at 5:15 am
  • Editorial Team
    Editorial Team added an answer The key is probably in the Gemfile. It is not… May 14, 2026 at 5:15 am
  • Editorial Team
    Editorial Team added an answer Use cell2mat. %# create a sample 2-by-2 cell array c… May 14, 2026 at 5:15 am

Related Questions

I come from a PHP based background and my new years resolution was to
I come from a php background and in php, there is an array_size() function
I come from a PHP background and would like to know if there's a
I come from a mainly PHP background and make good use of the Apache
This problem has been kicking my butt for a few days now. I have

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.