Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am trying to loop through a vectors elements and trying to find out if a position in the vector is equal to null...
if(_vecForShapes.get(i)!=null)//this line works fine but when it gets to a position where it is null it gives me an error? Any ideas?
{
}
Thanks!
Are you sure that it is get(i) that is null, and not that you have exceeded the number of items in _vecForShapes? It is much more likely that the _vecForShapes.get(i) is throwing an error than the comparison to null.
What type does get(i) return?
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 months ago.
Improve this question
Error on my flutter code regarding a dropdown
Exception has occurred.
_CastError (type 'List' is not a subtype of type 'String?' in type cast)
You are trying to cast list to a string thats why you get _CastError, when you use "[]" in dart, you actually declare a list, so either you need to change type String? selectedPlan to List<String>? selectedPlan or just remove the brackets like String? selectedPlan = 'FIXED DEPOSIT SAVINGS';
And please share code as code next time :)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 6 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
Firstly, I am storing the data in ArrayList.Now based on my index(current position) I want to replace that data with new data,but what I am getting is
old data,old data,old data,true,true,new data,new data....
Any suggestions
ArrayList<String> arr = new ArrayList<String>();
if (arr.isEmpty()) {
for(int i = 0;i<=mcq.size();i++) {
arr.add(s);
}
} else {
arr.set(currentPosition, String.valueOf(arr.add(s)));
}
"s" is a String value I am getting from somewhere else.
This looks really weird:
arr.set(currentPosition, String.valueOf(arr.add(s)));
ArrayList.set changes the elements stored at currentPosition. You want it to change it to the string value of what arr.add returns.
ArrayList.add returns a boolean, so there you get your true values from.
I think you want to do arr.set(currentPosition, s);
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
My error is :
weight = Float.parseFloat(etWeightBMI.getText().toString()); error is (1228): java.lang.NumberFormatException: Invalid float: ""
Before Parsing you should check
if(TextUtils.isEmpty(etWeightBMI.getText().toString()))
{
//do your job
}
etWeightBMI.getText().toString(); returns blank. Thats why you get the NPE.
This line returns null.
etWeightBMI.getText().toString();
Do this with validation like below:
if(etWeightBMI.getText().toString().trim().length()>0){
weight = Float.parseFloat(etWeightBMI.getText().toString());
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I wrote a code..There I want to validate something.In my code contain "HttpResponse response;" variable.I want to write,
if(response>="0"){
//do somthing
}
but can't above thing. bcs response is not string...How to do that?
EntityUtils is static helpers for dealing with entities.
http://www.developer.android.com/reference/org/apache/http/util/EntityUtils.html‎
String result = EntityUtils.toString(response);
if(result >="0"){
//do somthing
}
response.toString()
try that, you should also look at writing your questions more formally.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
This is my code:
blanks=new EditText(this);
String values =blanks.getText().toString();
answers.put(relative.getId(),answer);
if(answer[0].equals(values)) {
Toast.makeText(this,"Match!", Toast.LENGTH_LONG).show();
}
Your code makes no sense. You crate a new EditText field, and then immediately get the text. But this will always be null.