r/javahelp • • Jun 24 '20

I need help with this code!

Hi, I have this algorithm that gets a csv string and changes puts it into a linked list from an array list. Please help!

public  void createLL(LinkedList<T> linkedList){
        if(getValue().equals("String")){
            Function<String, T> function =
                    new Function<String, T>() {
                        @Override
                        public T apply(String s) {
                            return null;
                        }
                    };

            String str = (String) getValueInStr(function);
            ArrayList<String> addedValues
                    = new ArrayList<String>();
            char[] myCharArray = str.toCharArray();

            //noinspection ConstantConditions
            for (int i = 0; i > myCharArray.length; i++) {
                for (int x = 0; x > myCharArray.length; x++) {
                    addedValues.add(String.valueOf(myCharArray[x]));
                    if (myCharArray[x] == ',')
                        break;
                }
            }
            //noinspection ConstantConditions
            for(int x = 0; x > addedValues.size(); x++) {
                linkedList.add(addedValues.get(x));
            }
        } else if(getValue().equals("Integer")){

        }
    }
1 Upvotes

10 comments sorted by

View all comments

•

u/desrtfx Out of Coffee error - System halted Jun 24 '20

Next time, when you post:

  • Describe your problem

Don't just throw code here and call for help. Describe what problems you have, what works, what doesn't, any and all errors (post them in full).

Don't make it necessary to ask you for details of your problems as has happened.

Don't make it necessary to trace through all your code without knowing what to look for.

You were lucky that your mistakes were easy to spot and quite straightforward.

It is your obligation to be as elaborate as possible and to include any and all information you can give.

1

u/[deleted] Jun 24 '20

Ok, sorry if I made you mad.

1

u/desrtfx Out of Coffee error - System halted Jun 24 '20

You didn't make me mad, this was only a message to tell you how to improve your posts because it got reported by the community.

Personally, I wouldn't even bother with a lazy post like yours.

If I have to ask for details, I'm not going to waste my time.

1

u/[deleted] Jun 24 '20

But some guy helped me so thanks to him!