indexof

How I can access array elements of List

旧城冷巷雨未停 提交于 2021-02-16 22:46:51
问题 I have a question: I have a List Java that I have populated with different values. For example, I have: List<String[]> l = new ArrayList(); String[] lis = new String[3]; lis[0] = "A"; lis[1] = "B"; lis[2] = "C"; l.add(lis); and I have other values too. Now, I want to get the search in this list only the first field. For example, I want the A's indexOf. I have tried to write this code: int index = l.indexOf("A"); but I get -1 as return. I would like to know how I can access to a field of the

How I can access array elements of List

懵懂的女人 提交于 2021-02-16 22:45:30
问题 I have a question: I have a List Java that I have populated with different values. For example, I have: List<String[]> l = new ArrayList(); String[] lis = new String[3]; lis[0] = "A"; lis[1] = "B"; lis[2] = "C"; l.add(lis); and I have other values too. Now, I want to get the search in this list only the first field. For example, I want the A's indexOf. I have tried to write this code: int index = l.indexOf("A"); but I get -1 as return. I would like to know how I can access to a field of the

How I can access array elements of List

浪尽此生 提交于 2021-02-16 22:45:20
问题 I have a question: I have a List Java that I have populated with different values. For example, I have: List<String[]> l = new ArrayList(); String[] lis = new String[3]; lis[0] = "A"; lis[1] = "B"; lis[2] = "C"; l.add(lis); and I have other values too. Now, I want to get the search in this list only the first field. For example, I want the A's indexOf. I have tried to write this code: int index = l.indexOf("A"); but I get -1 as return. I would like to know how I can access to a field of the

IndexOf Method for Multiple Properties in Object Array

孤街浪徒 提交于 2021-02-16 05:19:17
问题 What's the best method to get the index of an object in an object array given multiple of it's properties? Imagine the following example array: var array = [ { color: 'red', shape: 'square', weight: 200 }, { color: 'blue', shape: 'circle', weight: 300 }, { color: 'red', shape: 'circle', weight: 100 } ]; Now I would like to have the indexOf the object which color property is red and shape is circle which, in this example, would be 2 . Ideally the function would return the index of the object

IndexOf Method for Multiple Properties in Object Array

筅森魡賤 提交于 2021-02-16 05:19:13
问题 What's the best method to get the index of an object in an object array given multiple of it's properties? Imagine the following example array: var array = [ { color: 'red', shape: 'square', weight: 200 }, { color: 'blue', shape: 'circle', weight: 300 }, { color: 'red', shape: 'circle', weight: 100 } ]; Now I would like to have the indexOf the object which color property is red and shape is circle which, in this example, would be 2 . Ideally the function would return the index of the object

IndexOf Method for Multiple Properties in Object Array

怎甘沉沦 提交于 2021-02-16 05:18:13
问题 What's the best method to get the index of an object in an object array given multiple of it's properties? Imagine the following example array: var array = [ { color: 'red', shape: 'square', weight: 200 }, { color: 'blue', shape: 'circle', weight: 300 }, { color: 'red', shape: 'circle', weight: 100 } ]; Now I would like to have the indexOf the object which color property is red and shape is circle which, in this example, would be 2 . Ideally the function would return the index of the object

JavaScript Search Table by Index

杀马特。学长 韩版系。学妹 提交于 2021-02-08 01:59:42
问题 I have a table with multiple columns (for this question I only made two columns) and I want the user to be able to search through a column by the index depending on an option that the user can select. I have working code, but in order to change the search option, I had to copy the function for each input. How can I search by the index? If a user selects an option like (name), then the javascript function will change the index that it is searching to [0]. if the user selects (location), the

How to find index of selected text in getSelection() using javascript?

懵懂的女人 提交于 2021-02-07 03:03:23
问题 I am trying to apply style to the text selected by the user(mouse drag) for which I need to get the start and end index of the selected text. I have tried using "indexOf(...)" method. but it returns the first occurrence of the selected substring. I want the actual position of the substring with respect to the original string. For example.., if I select the letter 'O' at position 3 [YOL O Cobe], I expect the index as 3 but the indexOf() method returns 1 which is the first occurrence of 'O' in

indexOf for angular typescript

核能气质少年 提交于 2021-01-29 12:35:17
问题 I am trying to write a similar true/false statement, Similar to how the .selected() method would work in Angular typescript . The idea is to show an image if the calculation or *ngIf statement evaluates to True . The code is written in the app.html side Code: <img src="/project/x.png" *ngIf="selectedimage.indexOf(v) !== -1"><a href="{{i['link']}}" target="blank" (click)="update_viewed(z)"> There is a *ngFor statement right before this code, with ;let z = index at the end. The overall code

Search a java.util.List starting at a specific index

穿精又带淫゛_ 提交于 2021-01-28 02:20:44
问题 Is there a built-in method to search a java.util.List specifying the first item to start the search from? Like you can do with Strings I know I can easily implement something on my own, but I'd rather not reinvent the wheel if Java or http://commons.apache.org/collections/api-release/org/apache/commons/collections/package-summary.html already has it. I'm not asking how to implement this, I'm asking whether something is already available A lot of the suggestions here were buggy. If anybody