Palindrome in Java with NUmbers [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am self studying java, i am on while loops already, I have an exercise here regarding a palindrome. what's a palindrome? how will code it? any ideas? or pseudocode for it? I am really confused here
NOT a HOMEWORK

Since its not homework, it shouldn't matter how you implement it.
public static <ToStringable> boolean isPalindrome(ToStringable stringable) {
String text = stringable.toString();
return text.equals(new StringBuilder(text).reverse().toString());
}

A palindrome is a sequence that reads the same backwards as forwards, like "kayak" or 12321.
See here: http://en.wikipedia.org/wiki/Palindrome
EDIT: there are also lots of questions about palindromes on stackoverflow already. Browse through them and come back if you have more specific questions:
https://stackoverflow.com/questions/tagged/palindrome

Palindrome is a sequence such that reversing the sequence gives you the same sequence. E.g. MAM

Related

Get a Java string of form (num/num), to become two double values [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
For example, if I have a string (24/25), how would I go about being left with two double values of 24 and 25. My objective to to eventually, given a set of number of that form, divide each of them, and add to get the average. I'm fairly new to Java and I honestly am so confused as where to even begin. Thank you!
As Andreas said. First you need to take the substring between brackets. Use String.substr
Now split 24/25 to 24 and 25. You can use String.split
Then you can parse them with Double.parse

Is there a RegEx that can satisfy all these conditions? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
The user input will only be accepted when,
Only upper case letters 'X','O','D','L','E' are present in the user input.
Any amount of 'O's only when in between 'D's
'DLE' is at the end and not by itself.
'X' counts as anything.
So for example the user input: 'DDLE', 'DOODLE', 'XXXDODOOOODLEDLX' - will work.
But these examples will not work ("error, wrong input"): 'DLE','DOOODLLE' 'DLEDOD'
based on criteria and examples provided
^(?=.+[DX][LX][EX]$)(?!.*[^DO]O+[^DO])[XODLE]+$
^(?=.+[DX][LX][EX]$)(?!.*[^DO]O+)(?!.*O+[^DO])[XODLE]+$
Demo
or depends on your interpretation of "'X' counts as anything" - meaning DOODDLEX is valid
^(?=.+[DX][LX][EX]X*$)(?!.*[^DO]O+[^DO])[XODLE]+$
^(?=.+[DX][LX][EX]X*$)(?!.*[^DO]O+)(?!.*O+[^DO])[XODLE]+$
or as suggested below
^(?=.+[DX][LX][EX]X*$)(?!.*[^DOX]O+)(?!.*O+[^DOX])[XODLE]+$

how to assign huge value variable [closed]

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
it is possible to assign that big number in java? i need to make a calculation of 39 digits value. could any help? Thanks
Problem:
Consider the following composite number:
340282367237851113557325445936183246849
Write a Java method to find two numbers whose product is the above number.
I guess you need to check out the BigInteger of the java API. That might be able to store your results of those much big numbers. Read the documentation,
http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html

Any webpage keyword count Algorithm in Java? [closed]

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
How to Calculate the Keyword Count in a Particular page in java. I want to Know the ALgo for that.
Boyer-Moore String Search Algo
If you want to talk about algorithm the string search algorithm famous is Boyer-Moore String search algorithm.
A Java based implementation of Boyer-Moore can be found at http://algs4.cs.princeton.edu/53substring/BoyerMoore.java.html
KMP Algorithm
Another algorithm which can search with substring too is Knuth-Morris-Pratt(KMP) algorithm.
A Java based implementation of KMP can be found at
http://tekmarathon.wordpress.com/2013/05/14/algorithm-to-find-substring-in-a-string-kmp-algorithm/
Load the HTML into a String and you're good to go. Answer to you next question is right here.

Looking for regex to find a sequence of characters [closed]

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 don't know a single bit about regex. I want to find certain occurences in my java project using eclipse. The words could be
SEQ_NUM
SEQNUM
SEQNUMBER
SEQ_NUMBER
searching strings based on word "seq" would generate lots of results. What regex should suffice my problem?
These four cases can be combined to the following regex:
SEQ_?NUM(BER)?
SEQ_?NUM(BER)?
SEQ - must exist
_? - '_' can appear 0 or 1 time
NUM - NUM must also exist
(BER)? - 'BER' can appear 0 or 1 time
This should work for you.
SEQ[_NUMBER]+

Categories