Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Repeated Character Count In java
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.*; import java.util.HashMap; import java.util.Map; import java.lang.*; class Rextester { public static void main(String args[]) { String s="HelloWorld"; findCountChar(s); } private static void findCountChar(String s){ Map<Character,Integer> l_map=new HashMap<Character,Integer>(); for(Character ch:s.toCharArray()){ if(l_map.containsKey(ch)){ l_map.put(ch,l_map.get(ch)+1); } else{ l_map.put(ch,1); } } Set<Character>l_ch=l_map.keySet(); for(Character ch:l_ch){ if(l_map.get(ch)>1){ System.out.println(ch+"-Repeated word is--"+l_map.get(ch)); } } } }
[
+
]
Show input
Compilation time: 0.73 sec, absolute running time: 0.2 sec, cpu time: 0.19 sec, memory peak: 18 Mb, absolute service time: 0,94 sec
fork mode
|
history
|
discussion
l-Repeated word is--3 o-Repeated word is--2