<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Thilak</title>
    <description>The latest articles on DEV Community by Thilak (@thilak).</description>
    <link>https://dev.to/thilak</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F629324%2F87a11871-a073-4312-ab0e-2d0c610c696e.png</url>
      <title>DEV Community: Thilak</title>
      <link>https://dev.to/thilak</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/thilak"/>
    <language>en</language>
    <item>
      <title>#Strings in Java</title>
      <dc:creator>Thilak</dc:creator>
      <pubDate>Thu, 25 Nov 2021 15:34:57 +0000</pubDate>
      <link>https://dev.to/thilak/strings-in-java-56a1</link>
      <guid>https://dev.to/thilak/strings-in-java-56a1</guid>
      <description>&lt;h1&gt;
  
  
  Strings
&lt;/h1&gt;

&lt;p&gt;Strings in Java are Objects that are backed internally by a char array. Since arrays are immutable(cannot grow), Strings are immutable as well. Whenever a change to a String is made, an entirely new String is created. &lt;/p&gt;

&lt;h1&gt;
  
  
  Syntax:
&lt;/h1&gt;

&lt;p&gt;String str = "abcd";&lt;/p&gt;

&lt;h1&gt;
  
  
  Memory allotment of String
&lt;/h1&gt;

&lt;p&gt;Whenever a String Object is created as a literal, the object will be created in String constant pool. This allows JVM to optimize the initialization of String literal.&lt;br&gt;
The string can also be declared using new operator i.e. dynamically allocated. In case of String are dynamically allocated they are assigned a new memory location in heap. This string will not be added to String constant pool.&lt;/p&gt;

&lt;h1&gt;
  
  
  Example:
&lt;/h1&gt;

&lt;p&gt;String str = new String("abcd");&lt;/p&gt;

&lt;h1&gt;
  
  
  An example that shows how to declare String
&lt;/h1&gt;

&lt;p&gt;import java.io.&lt;em&gt;;&lt;br&gt;
import java.lang.&lt;/em&gt;;&lt;/p&gt;

&lt;p&gt;class Test {&lt;br&gt;
    public static void main(String[] args)&lt;br&gt;
    {&lt;br&gt;
        // Declare String without using new operator&lt;br&gt;
        String s = "GeeksforGeeks";&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    // Prints the String.
    System.out.println("String s = " + s);

    // Declare String using new operator
    String s1 = new String("GeeksforGeeks");

    // Prints the String.
    System.out.println("String s1 = " + s1);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;br&gt;
Output: &lt;/p&gt;

&lt;p&gt;String s = GeeksforGeeks&lt;br&gt;
String s1 = GeeksforGeeks&lt;/p&gt;

</description>
      <category>programming</category>
      <category>java</category>
    </item>
    <item>
      <title>pointers</title>
      <dc:creator>Thilak</dc:creator>
      <pubDate>Tue, 11 May 2021 08:32:55 +0000</pubDate>
      <link>https://dev.to/thilak/pointers-24mf</link>
      <guid>https://dev.to/thilak/pointers-24mf</guid>
      <description>&lt;h1&gt;
  
  
  pointers:
&lt;/h1&gt;

&lt;p&gt;A pointer is a variable whose value is the address of another variable, i.e., direct address of the memory location. Like any variable or constant, you must declare a pointer before using it to store any variable address. The general form of a pointer variable declaration is −&lt;/p&gt;

&lt;p&gt;syntax:&lt;/p&gt;

&lt;p&gt;type *var-name;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;example:&lt;br&gt;
include &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;int main () {&lt;/p&gt;

&lt;p&gt;int  var = 20; &lt;br&gt;
   int  ip;        &lt;/p&gt;

&lt;p&gt;ip = &amp;amp;var;  &lt;/p&gt;

&lt;p&gt;printf("Address of var variable: %x\n", &amp;amp;var  );&lt;/p&gt;

&lt;p&gt;/* address stored in pointer variable */&lt;br&gt;
   printf("Address stored in ip variable: %x\n", ip );&lt;/p&gt;

&lt;p&gt;/* access the value using the pointer */&lt;br&gt;
   printf("Value of *ip variable: %d\n", *ip );&lt;/p&gt;

&lt;p&gt;return 0;&lt;br&gt;
}&lt;/p&gt;

&lt;h1&gt;
  
  
  Types of Pointers
&lt;/h1&gt;

&lt;p&gt;There are different types of pointers which are as follows −&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Null pointer

Void pointer

Wild pointer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;1.Null Pointer:&lt;/p&gt;

&lt;p&gt;You create a null pointer by assigning the null value at the time of pointer declaration.&lt;/p&gt;

&lt;p&gt;This method is useful when you do not assign any address to the pointer. A null pointer always contains value 0.&lt;/p&gt;

&lt;p&gt;syntax:&lt;/p&gt;

&lt;p&gt;Begin.&lt;br&gt;
   Declare a pointer p of the integer datatype.&lt;br&gt;
      Initialize *p= NULL.&lt;br&gt;
   Print “The value of pointer is”.&lt;br&gt;
      Print the value of the pointer p.&lt;br&gt;
End.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;example:&lt;br&gt;
include &lt;br&gt;
int main() {&lt;br&gt;
   int *p= NULL;//initialize the pointer as null.&lt;br&gt;
   printf("The value of pointer is %u",p);&lt;br&gt;
   return 0;&lt;br&gt;
}&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;2.Void Pointer:&lt;/p&gt;

&lt;p&gt;It is a pointer that has no associated data type with it. A void pointer can hold addresses of any type and can be typecast to any type.&lt;/p&gt;

&lt;p&gt;It is also called a generic pointer and does not have any standard data type.&lt;/p&gt;

&lt;p&gt;It is created by using the keyword void.&lt;/p&gt;

&lt;p&gt;syntax:&lt;br&gt;
Begin&lt;br&gt;
   Declare a of the integer datatype.&lt;br&gt;
      Initialize a = 7.&lt;br&gt;
   Declare b of the float datatype.&lt;br&gt;
      Initialize b = 7.6.&lt;br&gt;
   Declare a pointer p as void.&lt;br&gt;
   Initialize p pointer to a.&lt;br&gt;
   Print “Integer variable is”.&lt;br&gt;
      Print the value of a using pointer p.&lt;br&gt;
   Initialize p pointer to b.&lt;br&gt;
   Print “Float variable is”.&lt;br&gt;
      Print the value of b using pointer p&lt;br&gt;
End.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;example:&lt;br&gt;
include&lt;br&gt;
int main() {&lt;br&gt;
   int a = 7;&lt;br&gt;
   float b = 7.6;&lt;br&gt;
   void *p;&lt;br&gt;
   p = &amp;amp;a;&lt;br&gt;
   printf("Integer variable is = %d", ( (int) p) );&lt;br&gt;
   p = &amp;amp;b;&lt;br&gt;
   printf("\nFloat variable is = %f", ( (float) p) );&lt;br&gt;
   return 0;&lt;br&gt;
}&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;3.Wild Pointer:&lt;/p&gt;

&lt;p&gt;Wild pointers are also called uninitialized pointers. Because they point to some arbitrary memory location and may cause a program to crash or behave badly.&lt;/p&gt;

&lt;p&gt;syntax:&lt;br&gt;
include &lt;br&gt;
int main(){&lt;br&gt;
   int *p; //wild pointer&lt;br&gt;
   printf("\n%d",*p);&lt;br&gt;
   return 0;&lt;br&gt;
}&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;example:&lt;br&gt;
include &lt;br&gt;
int main(){&lt;br&gt;
   int *p; //wild pointer&lt;br&gt;
   printf("\n%d",*p);&lt;br&gt;
   return 0;&lt;br&gt;
}&lt;/p&gt;
&lt;/blockquote&gt;

</description>
    </item>
  </channel>
</rss>
