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 7 years ago.
Improve this question
I am using Java and have some problems.
I made two BigInteger variables, p and q.
In my code, I want to add if function, like if(p=1 \ q=1).
I tried many ways but there was error. Do you know how to solve this?
Your question is not completely clear, but you need to use the BigInteger.equals() method, as in this example:
if (BigInteger.equals(p, BigInteger.ONE) || BigInteger.equals(q, BigInteger.ONE)) {
// do something
}
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 9 days ago.
Improve this question
I have to make a massage out of a sentence. from this: "Jutri sem sama" to "ur e aaJtismsm" this.
What method should I use?
String sporocilo= JOptionPane.showInputDialog("Vpiši sporocilo");
int kodirano= sporocilo.length();
System.out.println(sporocilo);
System.out.println(kodirano);
for(int i=0; i<kodirano;i++){
if(sporocilo.length()%2!=0)
System.out.print(sporocilo.indexOf(i));
else
System.out.print(sporocilo.indexOf(i));
}
Like I said, I have to make a new massage out of the old one and I have to mix indekses.
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 3 years ago.
Improve this question
Suppose we have a string BE231231.
I need an output like this : BE0231231
need to append zero at a this fixed location in java inside a method
public String appendAtIndex(String base, String toAppend, int index){
return base.substring(0,index) + toAppend + base.substring(index);
}
You can implement the logic for restrictions on index accordingly so that base.substring does not give errors.
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 years ago.
Improve this question
Can anyone help me to write code that find how many characters string has.
All you need is - int len = yourString.length();
StringUtils should provide you with something that you are looking for:
int count = StringUtils.countMatches("haahaahaa", "a");
System.out.println(count);
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 7 years ago.
Improve this question
I have
String[] country={"USA","ks a","UK","France"};
I have a variable String z.
I want to say
if(z.equals(any element of my array (USA or ks or France)
but randomly:
if(z.equals(country[i]){
Doing action any code
}
Can anybody help me?
you can use
if ( Arrays.asList(country).contains(z)) {
// your code
}
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 have tried to return null as third value in my boolean function, but it won't compile. I need to return three values from my class method - true, false and null (for example). Is there any standard way how can I do it?
Please use an enumeration with three values defined. Hacking things together is no solution.
Similar question has been asked, it should help.
You can make your own POJO object with this logic in getXX() method. From your method return this POJO with value and test it in code.
Generaly, don't use null values as state indicators.