java - Cut off last half of String -


i need cut off half of user-entered string. i've tried , didn't work:

    scanner sc = new scanner(system.in);     string nameone = sc.nextline();     chars[] onechars = new char[nameone.length];     double onelength = onechars.length / 2;     math.round(onelength);     int onelen = (int)onelength;     string nameonefinal = "";     for(int = 0; == onelen--; i++) {         onechars[i] = onechars[onelen];         nameonefinal = nameonefinal + onechars[i];     } 

final int mid = nameone.length() / 2; string[] parts = {     nameone.substring(0, mid), // 1st part     nameone.substring(mid), // 2nd part }; 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -