[Solved] find the number of every letters in a word [closed]

Try this: public static void main(String[] args) { String input = “YYYCZZZZGG”; Map<Character, Integer> map = new HashMap<Character, Integer>(); // Map // to store character and its frequency. for (int i = 0; i < input.length(); i++) { Integer count = map.get(input.charAt(i)); // if not in map if (count == null) map.put(input.charAt(i), 1); else map.put(input.charAt(i), … Read more

[Solved] Java Timer : I want to fade in and out for my picture but there are some error [closed]

Screen size you cat get without using JFrame’s instance: screen = Toolkit.getDefaultToolkit().getScreenSize(); Also after creating JFrame, add a component listener to update width, height on any resize: JFrame frame = new JFrame(“fade frame”); frame.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { width = image.getWidth(frame); height = image.getHeight(frame); } }); solved Java Timer : I … Read more

[Solved] How to make regex accept only uppercase and lowercase letters with accents in java? [closed]

In my opinion You get true, because regex is focused on finding letters. It would say false only, when You test string with no letters at all. Please consider changing if else statement and regex to find out if there are other symbols than letters: Pattern pattern = Pattern.compile(“[^\w]”); Matcher matcher = pattern.matcher(“testTest”); if (matcher.find()){ … Read more

[Solved] Error: incompatible types

JTextField and String are not the same thing. You probably want to get the value from the text field like arrayWoord[0] = letterVeld1.getText(). Also, you should store the letterVelds in an array and just do for (int i = 0; i < 10; i++) arrayWoord[i] = letterVelds[i].getText(). solved Error: incompatible types

[Solved] A regex that doesn’t match with this character sequence

This answer is to demonstrate the possibility only. Using it in production code is questionable. It is possible with Java String replaceAll function: String input = “Hi, Mr.Xyz! Your account number is :- (1234567890) , (.*) &$@%#*(….))(((“; String output = input.replaceAll(“\\G((?:[^()\\[\\]{}?+\\\\.$^*|!&@#%_\”:<>/;’`~-]|\\Q(.*)\\E)*+)([()\\[\\]{}?+\\\\.$^*|!&@#%_\”:<>/;’`~-])”, “$1\\\\$2”); Result: “Hi, Mr\.Xyz\! Your account number is \:\- \(1234567890\) , (.*) \&\$\@\%\#\*\(\.\.\.\.\)\)\(\(\(” Another … Read more

[Solved] Time in milliseconds calculation

Here some tipps to get started: You can parse the String to a Java Date like this: SimpleDateFormat format = new SimpleDateFormat(“HH:mm:ss”); Date startTimer1Date = format.parse(StartTimer1); You can get the current Date and Time like this: Date dateNow = new Date(); And since you are working with time only (and not with date and time), … Read more

[Solved] How to get the public key? [closed]

I just downloaded your certificate and tested in my local import java.io.FileInputStream; import java.io.FileNotFoundException; import java.security.PublicKey; import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; public static void main(String[] args) throws FileNotFoundException, CertificateException { FileInputStream fin = new FileInputStream(“C://Users/admin/Desktop/uidai_auth_stage.cer”); CertificateFactory f = CertificateFactory.getInstance(“X.509”); X509Certificate certificate = (X509Certificate)f.generateCertificate(fin); PublicKey pk = certificate.getPublicKey(); System.out.println(pk); } Output Sun RSA public key, … Read more

[Solved] Java static instance

This code reminds me of Singleton Class in java. public class Runa { private static Runa singleton = new Runa( ); /* A private Constructor prevents any other * class from instantiating. */ private Runa() { } /* Static ‘instance’ method */ public static Runa getInstance( ) { return singleton; } /* Other methods protected … Read more

[Solved] Converting number to word

First of all take hundreds place digit by deviding by 100 and print corresponding number by calling method numberToWord((number / 100), ” HUNDRED”); since number / 100 would be in between 0 to 9 so it will print digit in word concatenated by HUNDRED. Now you left with two digit number for that you directly … Read more

[Solved] How to print number and “*” combination in java

this code will work try this………….:) public class simple { public static void main(String[] args) { // TODO Auto-generated method stub int n; n=3; for(int i=1;i<2*n;i++){ if(i<=n){ for(int j=1;j<i;j++){ System.out.print(i+”*”); } System.out.println(i); } else{ for(int j=i+1;j<2*n;j++){ System.out.print(2*n-i+”*”); } System.out.println(2*n-i); } } } } solved How to print number and “*” combination in java