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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:35:53+00:00 2026-06-06T19:35:53+00:00

I just saw someone post the following, in a rant on ugly code: public

  • 0

I just saw someone post the following, in a rant on ugly code:

public static 
    Tuple<ArrayList<ArrayList<ArrayList<String>>>, 
          ArrayList<ArrayList<ArrayList<String>>>>     
    split(
          ArrayList<ArrayList<ArrayList<String>>> data, [..]);

(layout by me, in a laughable attempt to get this semi-readable)

I’ve been looking for a way to make this look a bit like this (non-functional) code:

TypeParam T = ArrayList<ArrayList<ArrayList<String>>>;
public static Tuple<T,T> split( T data, [..]);

So far the best solution I’ve found is to define a class (in this ex. a class Data), which extends ArrayList<ArrayList<ArrayList<String>>>, which would make the code look like this:

public static Tuple<Data, Data> split( Data data, [..]);

While this method is quite satisfactory, I don’t want to give up on the possibility that there is some way of using generics that I’m missing, and I’m wondering if Java has a way of doing this in an even more aesthetically pleasing way.

Another solution I’m playing with is using an Annotation Processor to fix this for me, however I feel this misses a certain amount of simplicity.

  • 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-06T19:35:54+00:00Added an answer on June 6, 2026 at 7:35 pm

    How about

     public static <T extends ArrayList<ArrayList<String>>> Tuple<T,T> 
          split(T data);
    

    But I agree with @esej that you probably want some class to encapsulate the list-of-lists-of-lists-of-strings data structure.

    I am also not sure if you should have ArrayList hard-coded in there (as opposed to using the interface List).

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

Sidebar

Related Questions

I just saw this piece of javascript code at Facebook: javascript:eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return
I just going through code someone has written and I saw |= usage, looking
I just saw this code while studying the wordpress source code (PHP), You can
I just saw some code in our code base (and it's OLD code, as
I was looking at someone's code and saw that he repeatedly declared PrintStream out
I found the following code in SO. Does this really work? String xml =
I saw someone using label as an ItemRenderer for DataGrid, the code is here.
Here is my code structure, that I saw from someone else and am trying
I just saw a CSS code that included ::before tag. I looked at MDN
just saw this comment in a what JS lib do you use poll @Xanti

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.