Tuesday, July 17, 2018

Is String Immutable


Immutable simply mean unchangeable or unmodifiable. Once string object is created its data or state can't be changed
Consider bellow example,
class Testimmutablestring{  
  public static void main(String args[]){  
    String s="Future";  
    s.concat(" World");//concat() method appends the string at the end  
    System.out.println(s);//will print Future because strings are immutable objects  
  }  
 }  
Let's get idea considering bellow diagram,
enter image description here
In this diagram, you can see new object created as "Future World". But not change "Future".Because String is immutables, still refer to "Future". If you need to call "Future World",
String s="Future";  
s=s.concat(" World");  
System.out.println(s);//print Future World
Why are string objects immutable in java?
Because Java uses the concept of string literal. Suppose there are 5 reference variables, all refers to one object "Future".If one reference variable changes the value of the object, it will be affected to all the reference variables. That is why string objects are immutable in java.

Friday, July 6, 2018

diiffrent between set and list

https://beginnersbook.com/2014/07/difference-between-list-and-set-in-java/

What is the Cross-Site Request Forgery (CSRF) Attack

Cross-Site Request Forgery (CSRF)

Cross-Site Request Forgery is an attack that forces an end user to execute the unwanted action in the web application which there currently authenticated. (more CSRF)

Must watch
Ex -:http://www.baeldung.com/spring-security-csrf

And
https://stackoverflow.com/questions/5207160/what-is-a-csrf-token-what-is-its-importance-and-how-does-it-work

1
2
3
4
5
<form action="http://bank.com/transfer" method="POST">
    <input type="hidden" name="accountNo" value="5678"/>
    <input type="hidden" name="amount" value="1000"/>
    <input type="submit" value="Show Kittens Pictures"/>
</form>