#Java Advanced Stream Manipulation

45 messages · Page 1 of 1 (latest)

pale cloakBOT
#

Hey, @lavish mist!
Please remember to /close this post once your question has been answered!

dim plume
#

hmm

#

Interesting. I'll try

lavish mist
#

It has to be done only using Stream but u can use various data structure

#

These are my answer for :

#
  • get distribution of match per month
  • get the top5 cities where most match occured
#

where on second solution Match::getVille is Match::getCity (im french, Ville=City)

#

I can provide a try catch method to import data

finite fern
#

hellllo

lavish mist
#

Hello sir

finite fern
#

lmaoo i am just a kid

#

you cant use for loop or anything?

lavish mist
#

Nope, it has to be done using Stream

#

This is what makes it hard haha

#

I have a method that gives me an ArrayList<String> with both team that played for a specific match, this i can use

#

So i could have a map {[team1, team2]=nb_match, [team2, team3]=nb_match, ...}

#

But then i have no idea how to get the maximum value

finite fern
#

Match(date, home_team, away _team, home_score, away_score, tournament, city, country) what are the data type of all this

#

oh nvm

lavish mist
#

date is a Calendar object

#

else String or int

finite fern
#

oh

#

get the name of the team that played the most
only this is left??

lavish mist
#

Yeap

finite fern
#

get the amount of goal scored
get the number of match played by Belgium since 2000
can u show the code how u did this two i dont really know much about stream but i will to help

lavish mist
#

yes

#

it uses Lambda expressions

#

for total amount of goal scored

#

were e.getNb_buts_marque_equipe_dom() is just e.getHome_Score()

#

and e.getNb_buts_marque_equipe_vis() is just e.getAway_Score()

#

This for Belgium

#

where isPlaying simply returns a boolean if a match has the specific team as home or away team

finite fern
#

oh

#
    static long l;
    public static void main(String[] args) {
        List<Integer> list = List.of(1,3,4,1);
        list.stream().forEach(e-> l = l+e);
        System.out.println("total is: "+l );
    }
#

is this correct way of getting the total??

lavish mist
#

Sorry dude but I ain't gonna give you a course on basic stream manipulation, you can find this on web really fast and for my advanced question i'm not quite sur that if you start from there u can answer :/

finite fern
lavish mist
#

By team !

#

So it should aggregate the number the team has been home_team and the number the team has been away_team

lavish mist
#

Found a solution !