Skip to main content

Posts

Showing posts from December, 2019

upload a existing project from system to github

How to upload a existing project from system to github? Here, I will show a live example to upload a existing project from your machine to github. First of all I want you to understand that you should or can't upload your existing project directly to git hub website using github UI, as they dont provide any UI option to upload whole project at once. You need to install git hub on your system and then you can upload your project using shell/terminal/cmd. To download git click here --> https://git-scm.com/download/win Once it is installed, you need to create an git ccount or login to your git account if you already have. and then go to repositories create your new project repositories by your project name. you will see this below: , copy this line, you will need it. git remote add origin https://github.com/Prittz/Test1234.git git push -u origin master Now, go to the project folder on your system. and open terminal/cmd on that location. and the

Count each character and sort the string

Here we have shown how to count the character occurrence in the string and print in sorted way For example, you have a string : input : bbcann and your output would be 1b2c1n2 , means you have counted and also printed in sorted way from a to z. This is commonly asked questions on online test. public class App  {     public static void main( String[] args )     {         System.out.println( "Hello World!" );         System.out.print(countChracter("bbcann"));     }              static String countChracter(String s){     char[] carray=s.toCharArray();     Arrays.sort(carray);     HashMap<Character,Integer> hm = new HashMap<Character, Integer>();     for(char c : carray){     if(hm.containsKey(c)){     hm.put(c, hm.get(c)+1);     }else{     hm.put(c, 1);     }         }     String output="";     for(Map.Entry e: hm.entrySet()){     output=output+e.getKey()+e.getValue();     }     ret

C variable format to Java Variable String format : snakeCase to java convention and vice versa

How to convert snake case format containing underscore to java variable format and vice versa?  Usually c variable contains underscore between words but java contains firstletter is lowercase and other first letter in upper case. This is very famous test program usually asked in online test. example :  input = bb_cann_fb_hnh output = bbCannFbHnh and vice versa. public class VariableFormatter { public static void main( String[] args )     {         System.out.println(modifyVariableString("bb_cann_fb_hnh"));         System.out.println(modifyVariableString("bbCannFb"));           }        private static String modifyVariableString(String s) {    String output; //check if it is c variable    if(s.contains("_")){    output= javaFormatter(s);    }else{    output= cFormatter(s);    } return output; } private static String cFormatter(String string) {    string= string.replaceAll("([A-Z])", "