<?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: Abdelrhman khaled</title>
    <description>The latest articles on DEV Community by Abdelrhman khaled (@abdelrhmankhaled).</description>
    <link>https://dev.to/abdelrhmankhaled</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%2F1039618%2F1f6edfca-b9cb-49fa-a51d-3101ac416af5.jpeg</url>
      <title>DEV Community: Abdelrhman khaled</title>
      <link>https://dev.to/abdelrhmankhaled</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abdelrhmankhaled"/>
    <language>en</language>
    <item>
      <title>1D Array Revision by java</title>
      <dc:creator>Abdelrhman khaled</dc:creator>
      <pubDate>Wed, 12 Apr 2023 08:51:22 +0000</pubDate>
      <link>https://dev.to/abdelrhmankhaled/1d-array-revision-by-java-4961</link>
      <guid>https://dev.to/abdelrhmankhaled/1d-array-revision-by-java-4961</guid>
      <description>&lt;p&gt;Quickly, we will recap about 1D array and do some iterations on it&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Declaration&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;DataType nameOfArray [] = new DataType [lengthOfArray];&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Example&lt;br&gt;
&lt;code&gt;int array [] = new int [5];&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If I want to &lt;strong&gt;access&lt;/strong&gt; an element in array &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;ArrayName[index]&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;code&gt;array[2];&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note that arrays is zero based:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Array of length 5&lt;br&gt;
The &lt;em&gt;1st&lt;/em&gt; element in array[0]&lt;br&gt;
The &lt;em&gt;last&lt;/em&gt; element array[lengthOfArray-1] = array[4]&lt;/p&gt;

&lt;p&gt;Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int array [] = new int [5];
array [0] = 7;
array [1] = 23;
array [2] = 20;
array [3] = 17;
array [4] = 45;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;System.out.println( array[0] );        // will print 7&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;looping on 1D array&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;For (int i=0 ; i&amp;lt;array.length();i++)
{
System.out.println(array[i] ) ;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Great questions need some one to solve
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;1st and easy question&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1YSm0TE1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/esd6lntp0n9oofgd9xai.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1YSm0TE1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/esd6lntp0n9oofgd9xai.png" alt="Image description" width="800" height="646"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;2nd question and easy too&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wybwnk12--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k2ao0256kn4uyjkj477c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wybwnk12--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k2ao0256kn4uyjkj477c.png" alt="Image description" width="800" height="493"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--r0cqAk3a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aug8vwqakqblou1aqhvm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--r0cqAk3a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aug8vwqakqblou1aqhvm.png" alt="Image description" width="800" height="602"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aVlBCzji--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i3766d2tq93r1nbpvay9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aVlBCzji--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i3766d2tq93r1nbpvay9.png" alt="Image description" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;last one but is medium !&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_aSx_ACL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zyedy9a5qha661v9vk36.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_aSx_ACL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zyedy9a5qha661v9vk36.png" alt="Image description" width="800" height="516"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ayLt8zpu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ji6nc4448b8sa876tir7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ayLt8zpu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ji6nc4448b8sa876tir7.png" alt="Image description" width="800" height="319"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>array</category>
    </item>
    <item>
      <title>Java HackerRank AUFS Season 6</title>
      <dc:creator>Abdelrhman khaled</dc:creator>
      <pubDate>Mon, 06 Mar 2023 12:43:17 +0000</pubDate>
      <link>https://dev.to/abdelrhmankhaled/java-hackerrank-aufs-season-6-23oj</link>
      <guid>https://dev.to/abdelrhmankhaled/java-hackerrank-aufs-season-6-23oj</guid>
      <description>&lt;h2&gt;
  
  
  &lt;em&gt;What we toke in session 2&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1- how to print a sentence&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;System.out.print("hello in HackerRank");&lt;/code&gt;&lt;br&gt;
or &lt;br&gt;
&lt;code&gt;System.out.println("hello in HackerRank with");&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;special characters needed to print&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;\\   will print \&lt;/li&gt;
&lt;li&gt;\'   will print '&lt;/li&gt;
&lt;li&gt;\"   will print "&lt;/li&gt;
&lt;li&gt;\n   will make a new line&lt;/li&gt;
&lt;li&gt;\t   will make a horizontal tab&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;let's print that sentence &lt;/p&gt;

&lt;p&gt;hello\Abdelrhman\2002\new Year&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;System.out.println("hello\\Abdelrhman\\2002\\new year");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;take care if you want to print \ or another special characters, to print it in the form\\.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2- naming identifiers&lt;/strong&gt;&lt;br&gt;
an identifier (a variable name) can be a sequence of Unicode characters that represent letters, digits 0-9, a dollar sign ($), or an underscore (_).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;some limitations&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The first symbol of an identifier cannot be a digit.&lt;/li&gt;
&lt;li&gt;An identifier cannot have the same spelling as a keyword.&lt;/li&gt;
&lt;li&gt;It cannot be spelled as the boolean literal true or false, and or as the literal null.&lt;/li&gt;
&lt;li&gt;an identifier cannot be just an underscore (_).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Here are a few unusual but legal examples of identifiers:&lt;/em&gt;&lt;br&gt;
$$&lt;br&gt;
_30 &lt;br&gt;
String&lt;br&gt;
ατηρε&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3- Data Types&lt;/strong&gt;&lt;br&gt;
here is some data types we have in java&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Boolean&lt;br&gt;
to store true or false&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;short&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;int &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;long&lt;br&gt;
to store Integer numbers&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;float&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;double&lt;br&gt;
to store Decimal numbers like 3.31 &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;char&lt;br&gt;
to store a single character &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Stirng&lt;br&gt;
to store a text&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;that's good but what is the difference between short, int, long ?&lt;br&gt;
Is the maximum and minimum value that can hold .&lt;/p&gt;

&lt;p&gt;So let's see what is the maximum and minimum value that short dataType can hold&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;System.out.println(Short.MAX_VALUE);
System.out.println(Short.MIN_VALUE);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;that will print&lt;br&gt;
32767&lt;br&gt;
-32768&lt;/p&gt;

&lt;p&gt;so if you try to store a value like 999999 in a short variable it will give an error.&lt;/p&gt;

&lt;p&gt;try to know maximum and minimum value that int and long can hold&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;System.out.println(Integer.MAX_VALUE);
System.out.println(Integer.MIN_VALUE);

System.out.println(Long.MAX_VALUE);
System.out.println(Long.MIN_VALUE);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;NOW let's assign a value to a variable&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int age = 21;
String name = "Abdelrhman Khaled";
System.out.println("My name is: "+name +" And my age is: "+age);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4- some usefull functions in class Integer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's try to convert numbers from int to Binary and Octal...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;System.out.println(Integer.toBinaryString(42));
System.out.println(Integer.toOctalString(42));
System.out.println(Integer.toHexString(42));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is very great the representation of number 42&lt;br&gt;
in Binary is 101010&lt;br&gt;
and in Octal 2a&lt;br&gt;
and in HexaDecimal 52&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5- Some Logic operations in java&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;to represent AND operation we use that symbol &amp;amp;&amp;amp;&lt;/li&gt;
&lt;li&gt;to represent  OR operation we use that symbol ||&lt;/li&gt;
&lt;li&gt;to know the equality we use ==&lt;/li&gt;
&lt;li&gt;and to assign a value to variable we use = &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;6- Ternary operation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The ? : operator is called a ternary operator. It evaluates a condition (before the sign ?) and, if it results in true, assigns to a variable the value calculated by the first expression (between the ? and : signs); otherwise, it assigns the value calculated by the second expression (after the : sign)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int n = 1, m = 2;
float k = n &amp;gt; m ? (n * m + 3) : ((float)n / m);
System.out.println(k);            //prints: 0.5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;7- we spoke about typeCasting&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;if you try to divide integer number on interger number the outPut must be integer.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;System.out.println(5/2);   //that will print 2&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And that is a problem the fraction disappeared !&lt;br&gt;
&lt;em&gt;So if you want to save the fraction you must divide Double or Float on that number&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;System.out.println(5.0/2);     // Wow that's awesome the outPut is 2.5&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;that we done is called type case, and there is to ways to case from int to double&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;multiply the number with 1.0&lt;/li&gt;
&lt;li&gt;or and (double)before the number&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;8- finally we spoke about if statement&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;and the style of write it is&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if(condition){
            //do that orders
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OR&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if(condition){
            //if the condition is true do that 
}else{
            // it the condition is false do that 
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OR&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if(condition1){
           //if condition1 is true do that 
}else if(condition2){
           //if condition1 is false and condition2 is true do that 
}else {
           // if there isn't any condition is true do that
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;9- At the end of that session we spoke about loops and forLoop&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;if you want to repeat some thing many times&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for(inti , condition , increment){
      //the thing we want to be repeated
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (int i = 0; i &amp;lt; 10; i++) {
            System.out.println(i);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;find the summation of numbers from 1 to n&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Scanner sc = new Scanner(System.in);
int number = sc.nextInt(); 
int sum = 0 ;
for(int i = 1; i &amp;lt;= number ; i++){
      sum +=i;
}
System.out.println("The summation of numbers from 1 to "+n+" is equals "+sum);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>java</category>
    </item>
  </channel>
</rss>
