Skip to content

Instantly share code, notes, and snippets.

@settermjd
Last active April 14, 2020 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save settermjd/b4bfdf5191afaaad5d5936916d47e447 to your computer and use it in GitHub Desktop.
Save settermjd/b4bfdf5191afaaad5d5936916d47e447 to your computer and use it in GitHub Desktop.
Examples of the same class in multiple c-based languages
class HelloWorld {
private String name;
public HelloWorld(String name) {
this.name = name;
}
public void printName() {
System.out.println(this.name);
}
public static void main(String[] args) {
HelloWorld obj = new HelloWorld("Matthew Setter");
obj.printName();
}
}
<?php
class HelloWorld
{
private $name = '';
public function __construct(string $name) {
$this->name = $name;
}
public function printName() {
print $this->name;
}
}
$obj = new HelloWorld('Matthew Setter');
echo $obj->printName();
class HelloWorld:
name = ""
def __init__(self, name):
self.name = name
def printName(self):
print(self.name)
# Instantiate and call the printName method
obj = HelloWorld("Matthew Setter")
obj.printName()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment