how to convert string to int in Java -


this question has answer here:

i'm working on caesar cipher example in want different keys user , 1 key decrypt original text , got problem, here code

public static void main(string[] args) {     scanner user_input= new scanner(system.in);     string plaintext = "university of malakand";     string key;     key = user_input.next();      ceasercipher cc = new ceasercipher();      string ciphertext = cc.encrypt(plaintext,key);     system.out.println("your plain  text :" + plaintext);     system.out.println("your cipher text :" + ciphertext);      string cplaintext = cc.decrypt(ciphertext,key);     system.out.println("your plain text  :" + cplaintext); } 

it shows error on line

    string ciphertext = cc.encrypt(plaintext,key); 

it shows me error on key incompatible types:

string cannot converted int

what can do?

ask following questions self first.

  • what method want parameter?
  • why both incompatible?
  • what string ciphertext = cc.encrypt(plaintext,key); mean?
  • key string or int?

use methods integer.parseint(string value) or integer.valueof(string value) conversion.


Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -