{"id":1337,"date":"2022-03-03T07:01:19","date_gmt":"2022-03-03T07:01:19","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=1337"},"modified":"2022-03-03T07:01:19","modified_gmt":"2022-03-03T07:01:19","slug":"convert-int-type-to-char","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/03\/03\/convert-int-type-to-char\/","title":{"rendered":"Convert int type to char"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Java Program to Convert int to char<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>class Main {\n  public static void main(String&#91;] args) {\n\n    \/\/ create int variables\n    int num1 = 80;\n    int num2 = 81;\n\n    \/\/ convert int to char\n    \/\/ typecasting\n    char a = (char)num1;\n    char b = (char)num2;\n\n    \/\/ print value\n    System.out.println(a);    \/\/ P\n    System.out.println(b);    \/\/ Q\n  }\n}<\/code><\/pre>\n\n\n\n<p>In the above example, we have&nbsp;<code>int<\/code>&nbsp;type variables&nbsp;<var>num1<\/var>&nbsp;and&nbsp;<var>num2<\/var>. Notice the line,<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>char a = (char)num1;<\/code><\/pre>\n\n\n\n<p>Here, we are using typecasting to covert an\u00a0<code>int<\/code>\u00a0type variable into the\u00a0<code>char<\/code>\u00a0type variable. <\/p>\n\n\n\n<p>Note that the&nbsp;<code>int<\/code>&nbsp;values are treated as ASCII values. Hence, we get&nbsp;<strong>P<\/strong>&nbsp;for&nbsp;<code>int<\/code>&nbsp;value&nbsp;<strong>80<\/strong>&nbsp;and&nbsp;<strong>Q<\/strong>&nbsp;for&nbsp;<code>int<\/code>&nbsp;value&nbsp;<strong>81<\/strong>. It is because the ASCII value of&nbsp;<strong>P<\/strong>&nbsp;and&nbsp;<strong>Q<\/strong>&nbsp;are&nbsp;<strong>80<\/strong>&nbsp;and&nbsp;<strong>81<\/strong>&nbsp;respectively.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java Program to Convert int to char In the above example, we have&nbsp;int&nbsp;type variables&nbsp;num1&nbsp;and&nbsp;num2. Notice the line, Here, we are using typecasting to covert an\u00a0int\u00a0type variable into the\u00a0char\u00a0type variable. Note that the&nbsp;int&nbsp;values are treated as ASCII values. Hence, we get&nbsp;P&nbsp;for&nbsp;int&nbsp;value&nbsp;80&nbsp;and&nbsp;Q&nbsp;for&nbsp;int&nbsp;value&nbsp;81. It is because the ASCII value of&nbsp;P&nbsp;and&nbsp;Q&nbsp;are&nbsp;80&nbsp;and&nbsp;81&nbsp;respectively.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[287],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/1337"}],"collection":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=1337"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/1337\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=1337"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=1337"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=1337"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}