r/javahelp • • Apr 01 '22

help with java code

hi i’m trying to write code for an assignment and a part of my code (i < drywet.length && i < wetwet.length) are underlined red. it says “the operator < is undefined for the argument type(s) int, Object”

can someone please explain what i need to do to fix it?

0 Upvotes

14 comments sorted by

•

u/AutoModerator Apr 01 '22

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions

  • You include any and all error messages in full

  • You ask clear questions

  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

    Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

3

u/FavorableTrashpanda Apr 01 '22

Not enough information.

-3

u/rpgirl5284 Apr 01 '22

could you dm me? i’m honestly not sure what more you’d like

3

u/scatteredRobot Apr 01 '22

Well what is I what are wetwet and wetdry and what is length? Are they objects, functions, or variables and if so what type?

3

u/desrtfx Out of Coffee error - System halted Apr 02 '22

See Rule #7

Asking for or offering help outside the subreddit is explicitly forbidden. This is so that more people can chime in and help as well as benefit from the given help.

Read /u/Automoderator's comment. It will tell you what all is needed.

4

u/chickenmeister Extreme Brewer Apr 01 '22

It's hard to give an answer without more information; but the error message is saying that you're trying to compare an int to an object. So I'd recommend double checking that drywet.length and wetwet.length are actually numerical values, rather than some kind of object.

2

u/Op_2873 Apr 01 '22

Did you define i ?

2

u/wildjokers Apr 01 '22

There is not enough code posted to help. Please take a look at the automod message.

We need much more code that at least shows declaration of i, drywet, wetwet. And if drywet and wetwet are custom objects we need to see at least the field declarations in those.

The error says you are comparing an int to an object. You can’t do that. Without more code though we can’t help you figure out what is wrong.

1

u/D0CTOR_ZED Apr 01 '22

Do they have a length field or are you trying to call a method? If you are calling a method, do you need to provide any parameters?

1

u/clinical27 Apr 02 '22

I can't say for sure as I don't have all the info of what these variables are, but I would assume 'i' is some sort of counter so it is probably an int, so is drywet or wetwet an object? If so, your length field may not be defined properly to return a value that can be compared.

0

u/[deleted] Apr 01 '22

Youre super close. Its the syntax with the way you have it written, right idea. Super close

-1

u/rpgirl5284 Apr 01 '22

okay how do i fix it

1

u/[deleted] Apr 02 '22

Per the rules of the subreddit, i cant give away answes. Look up how to use boolean operators

1

u/Actual_Fapper37 Apr 19 '22

Can you text me. My account is new i cant text you.