I'm starting to learn java after thoroughly learning python. In python, there is a function that saved me often, is it .index () Is there anything similar in java?

Well, in general. Does it make sense to teach java for game dev?

  • if you don't like C ++ for games, then you can pass C # to UNITY. There are fewer problems with writing code, but there are all the pros and cons of UNITY. Java, except for browser games ... - Vasyl Kolomiets

2 answers 2

The List interface has a method called indexOf (Object o) if you need a method to search for the index of an object.

If this list doesn’t contain the element

Java is well suited for developing server-side online games.

  • Also a compilation error. How to write correctly? arr.indexOf ( item which is in arr )? - Kirill Leontyev
  • This is a List interface method, not an array. You can wrap an array in a sheet using the static method of the Arrays class. Then the code will look like this: java.util.Arrays.asList (arr) .indexOf (object) - bengan
  • Oh java java ... Thank you, I will be telling you - Kirill Leontyev

In game dev, C ++ is the industry standard, and if among scripting languages, then Lua. Java has a contains () method in the List.

  • I use contains () - compilation error. How to use it correctly, right? arr.contains ( any item ) - Kirill Leontiev
  • So, apparently I was mistaken, but oh well, we have already written above about indexOf (). All the same advice about the PL concerns about the client side. - Dadaskis