This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.knoldus.kip.models | |
class Stack(stackWithList: List[Int]) { | |
def pop: Stack = { | |
if(stackWithList.isEmpty) { | |
throw new RuntimeException | |
} | |
new Stack(stackWithList.tail) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Models.Category | |
import Services.{SalaryDepositService, UserAccountService} | |
import akka.actor.{ActorSystem, Props} | |
import scala.concurrent.Future | |
import scala.concurrent.ExecutionContext.Implicits.global | |
object MainClass extends App { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class Person { | |
private String firstName; | |
private String lastName; | |
private String middleName = ""; | |
private String facebookId = ""; | |
private String twitterId = ""; | |
public Person() {} | |
//Setters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class Person { | |
//required fields | |
private final String firstName; | |
private final String lastName; | |
//optional fields | |
private final String middleName; | |
private final String facebookId; | |
private final String twitterId; | |
public Person(String firstName, String lastName, String middleName, String facebookId, String twitterId) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class JavaBeansExample { | |
public static void main(String[] args) { | |
Person person = new Person(); | |
person.setFirstName("Akshansh"); | |
person.setFacebookId("akshansh.jain.95"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class Person { | |
private final String firstName; | |
private final String lastName; | |
private final String middleName; | |
private final String facebookId; | |
private final String twitterId; | |
public static class Builder { | |
private final String firstName; | |
private final String lastName; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BuilderExample { | |
public static void main(String[] args) { | |
Person person = new Person.Builder("Akshansh", "Jain").facebookId("akshansh.jain.95").build(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Atomicity { | |
int i; | |
public void incrementNumber() { | |
i = i + 1; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Atomicity { | |
int i; | |
public void incrementNumber() { | |
i = 1; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.atomic.AtomicInteger; | |
public class Atomicity { | |
AtomicInteger i; | |
public void incrementNumber() { | |
i.incrementAndGet(); | |
} | |
} |
OlderNewer