In Visual Basic.NET, the Friend keyword talks about accessibility. In C #, the equivalent keyword is internal .
There is no such keyword in Java, but you can effectively get the same visibility in relation to the package area, leaving the access specifier class in the description of the declaration.
Taken from a comparative comparison between C # and Java versions of the same class declarations (I also added a Visual Basic version for completeness), pay attention to class B declarations, as well as AY , BY , CY and DY :
Visual Basic Version:
Public Class A Public Shared X As Integer Friend Shared Y As Integer Private Shared Z As Integer End Class Friend Class B Public Shared X As Integer Friend Shared Y As Integer Private Shared Z As Integer Public Class C Public Shared X As Integer Friend Shared Y As Integer Private Shared Z As Integer End Class Private Class D Public Shared X As Integer Friend Shared Y As Integer Private Shared Z As Integer End Class End Class
C # Version:
public class A { public static int X; internal static int Y; private static int Z; } internal class B { public static int X; internal static int Y; private static int Z; public class C { public static int X; internal static int Y; private static int Z; } private class D { public static int X; internal static int Y; private static int Z; } }
Java version:
public class A { public static int X; static int Y; private static int Z; } class B { public static int X; static int Y; private static int Z; public class C { public static int X; static int Y; private static int Z; } private class D { public static int X; static int Y; private static int Z; } }
See also this comparison of Visual Basic and C # for reference.
source share